* [PATCH] ASoC: tlv320aic3x: Fix null pointer dereference when pdata is not set
@ 2010-09-05 16:10 Jarkko Nikula
2010-09-06 9:45 ` Mark Brown
0 siblings, 1 reply; 3+ messages in thread
From: Jarkko Nikula @ 2010-09-05 16:10 UTC (permalink / raw)
To: alsa-devel; +Cc: Mark Brown, Jiri Slaby, Liam Girdwood
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>
---
sound/soc/codecs/tlv320aic3x.c | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index 8577c50..b317586 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,
const struct i2c_device_id *id)
{
struct aic3x_pdata *pdata = i2c->dev.platform_data;
- struct aic3x_setup_data *setup = pdata->setup;
struct aic3x_priv *aic3x;
int ret, i;
const struct i2c_device_id *tbl;
@@ -1372,15 +1371,18 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
}
aic3x->control_data = i2c;
- aic3x->setup = setup;
i2c_set_clientdata(i2c, aic3x);
+ if (pdata) {
+ aic3x->gpio_reset = pdata->gpio_reset;
+ aic3x->setup = pdata->setup;
+ } else {
+ aic3x->gpio_reset = -1;
+ }
- aic3x->gpio_reset = -1;
- if (pdata && pdata->gpio_reset >= 0) {
- ret = gpio_request(pdata->gpio_reset, "tlv320aic3x reset");
+ if (aic3x->gpio_reset >= 0) {
+ ret = gpio_request(aic3x->gpio_reset, "tlv320aic3x reset");
if (ret != 0)
goto err_gpio;
- aic3x->gpio_reset = pdata->gpio_reset;
gpio_direction_output(aic3x->gpio_reset, 0);
}
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] ASoC: tlv320aic3x: Fix null pointer dereference when pdata is not set
2010-09-05 16:10 [PATCH] ASoC: tlv320aic3x: Fix null pointer dereference when pdata is not set Jarkko Nikula
@ 2010-09-06 9:45 ` Mark Brown
2010-09-06 10:39 ` Liam Girdwood
0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2010-09-06 9:45 UTC (permalink / raw)
To: Jarkko Nikula; +Cc: alsa-devel, Jiri Slaby, Liam Girdwood
On Sun, Sep 05, 2010 at 07:10:22PM +0300, Jarkko Nikula wrote:
> 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>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: tlv320aic3x: Fix null pointer dereference when pdata is not set
2010-09-06 9:45 ` Mark Brown
@ 2010-09-06 10:39 ` Liam Girdwood
0 siblings, 0 replies; 3+ messages in thread
From: Liam Girdwood @ 2010-09-06 10:39 UTC (permalink / raw)
To: Mark Brown; +Cc: alsa-devel, Jiri Slaby
On Mon, 2010-09-06 at 10:45 +0100, Mark Brown wrote:
> On Sun, Sep 05, 2010 at 07:10:22PM +0300, Jarkko Nikula wrote:
> > 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>
Applied.
Thanks
Liam
--
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-09-06 10:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-05 16:10 [PATCH] ASoC: tlv320aic3x: Fix null pointer dereference when pdata is not set Jarkko Nikula
2010-09-06 9:45 ` Mark Brown
2010-09-06 10:39 ` Liam Girdwood
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.