diff options
author | Axel Lin <axel.lin@gmail.com> | 2010-07-23 01:53:49 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-08-03 02:45:20 -0400 |
commit | db1e18de98c8bdf8a2bfc07623ff67621aa4a332 (patch) | |
tree | 3681c2d5823befcc606d95bd06f5c4ca310986ae | |
parent | 62f5ad6733b872e14d671b615850eb5bd1cd7e30 (diff) |
ASoC: wm8940: fix a memory leak if wm8940_register return error
This patch adds checking for wm8940_register return value,
and does kfree(wm8940) if wm8940_register() fail.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r-- | sound/soc/codecs/wm8940.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/sound/soc/codecs/wm8940.c b/sound/soc/codecs/wm8940.c index e3c4bbfaae27..f0c11138e610 100644 --- a/sound/soc/codecs/wm8940.c +++ b/sound/soc/codecs/wm8940.c | |||
@@ -845,6 +845,7 @@ static void wm8940_unregister(struct wm8940_priv *wm8940) | |||
845 | static int wm8940_i2c_probe(struct i2c_client *i2c, | 845 | static int wm8940_i2c_probe(struct i2c_client *i2c, |
846 | const struct i2c_device_id *id) | 846 | const struct i2c_device_id *id) |
847 | { | 847 | { |
848 | int ret; | ||
848 | struct wm8940_priv *wm8940; | 849 | struct wm8940_priv *wm8940; |
849 | struct snd_soc_codec *codec; | 850 | struct snd_soc_codec *codec; |
850 | 851 | ||
@@ -858,7 +859,11 @@ static int wm8940_i2c_probe(struct i2c_client *i2c, | |||
858 | codec->control_data = i2c; | 859 | codec->control_data = i2c; |
859 | codec->dev = &i2c->dev; | 860 | codec->dev = &i2c->dev; |
860 | 861 | ||
861 | return wm8940_register(wm8940, SND_SOC_I2C); | 862 | ret = wm8940_register(wm8940, SND_SOC_I2C); |
863 | if (ret < 0) | ||
864 | kfree(wm8940); | ||
865 | |||
866 | return ret; | ||
862 | } | 867 | } |
863 | 868 | ||
864 | static int __devexit wm8940_i2c_remove(struct i2c_client *client) | 869 | static int __devexit wm8940_i2c_remove(struct i2c_client *client) |