aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/tlv320aic3x.c
diff options
context:
space:
mode:
authorJarkko Nikula <jhnikula@gmail.com>2010-09-05 12:10:22 -0400
committerLiam Girdwood <lrg@slimlogic.co.uk>2010-09-06 06:36:22 -0400
commitc776357e0adc2a25bd22eb75155030132c88a0dd (patch)
tree917edb0d57554a9a1a68ab471c41cdbede3617af /sound/soc/codecs/tlv320aic3x.c
parent098b1718230466b48f2027eb26cdc921760ae5da (diff)
ASoC: tlv320aic3x: Fix null pointer dereference when pdata is not set
Null pointer dereference will occur from *setup = pdata->setup if pdata is not set. Fix this by moving assignments from pdata inside non-null case. Thanks to Jiri Slaby <jirislaby@gmail.com> for noticing. Signed-off-by: Jarkko Nikula <jhnikula@gmail.com> Cc: Jiri Slaby <jirislaby@gmail.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'sound/soc/codecs/tlv320aic3x.c')
-rw-r--r--sound/soc/codecs/tlv320aic3x.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index 8577c50d8d22..b3175860bcb4 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -1360,7 +1360,6 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
1360 const struct i2c_device_id *id) 1360 const struct i2c_device_id *id)
1361{ 1361{
1362 struct aic3x_pdata *pdata = i2c->dev.platform_data; 1362 struct aic3x_pdata *pdata = i2c->dev.platform_data;
1363 struct aic3x_setup_data *setup = pdata->setup;
1364 struct aic3x_priv *aic3x; 1363 struct aic3x_priv *aic3x;
1365 int ret, i; 1364 int ret, i;
1366 const struct i2c_device_id *tbl; 1365 const struct i2c_device_id *tbl;
@@ -1372,15 +1371,18 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
1372 } 1371 }
1373 1372
1374 aic3x->control_data = i2c; 1373 aic3x->control_data = i2c;
1375 aic3x->setup = setup;
1376 i2c_set_clientdata(i2c, aic3x); 1374 i2c_set_clientdata(i2c, aic3x);
1375 if (pdata) {
1376 aic3x->gpio_reset = pdata->gpio_reset;
1377 aic3x->setup = pdata->setup;
1378 } else {
1379 aic3x->gpio_reset = -1;
1380 }
1377 1381
1378 aic3x->gpio_reset = -1; 1382 if (aic3x->gpio_reset >= 0) {
1379 if (pdata && pdata->gpio_reset >= 0) { 1383 ret = gpio_request(aic3x->gpio_reset, "tlv320aic3x reset");
1380 ret = gpio_request(pdata->gpio_reset, "tlv320aic3x reset");
1381 if (ret != 0) 1384 if (ret != 0)
1382 goto err_gpio; 1385 goto err_gpio;
1383 aic3x->gpio_reset = pdata->gpio_reset;
1384 gpio_direction_output(aic3x->gpio_reset, 0); 1386 gpio_direction_output(aic3x->gpio_reset, 0);
1385 } 1387 }
1386 1388