From: Dan Carpenter Date: Mon, 6 Apr 2009 01:50:46 +0000 (+0200) Subject: ASoC: Fix null dereference in ak4535_remove() X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=09318c47b6121c8d18cee50ca7e270a8b7dfd274;p=linux-2.6-omap-h63xx.git ASoC: Fix null dereference in ak4535_remove() ak4535_remove() from sound/soc/codecs/ak4535.c calls i2c_unregister_device() with a possibly null pointer. This bug was found by smatch (http://repo.or.cz/w/smatch.git/). Signed-off-by: Dan Carpenter Signed-off-by: Mark Brown --- diff --git a/sound/soc/codecs/ak4535.c b/sound/soc/codecs/ak4535.c index 1f63d387a2f..dd338020276 100644 --- a/sound/soc/codecs/ak4535.c +++ b/sound/soc/codecs/ak4535.c @@ -659,7 +659,8 @@ static int ak4535_remove(struct platform_device *pdev) snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) - i2c_unregister_device(codec->control_data); + if (codec->control_data) + i2c_unregister_device(codec->control_data); i2c_del_driver(&ak4535_i2c_driver); #endif kfree(codec->private_data);