diff options
author | Axel Lin <axel.lin@gmail.com> | 2010-07-23 07:53:45 +0200 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-08-03 08:43:52 +0200 |
commit | 085efd28b65582fac459359672421a1c479e7db1 (patch) | |
tree | e3c757bd4bacb91e164588d5c7af39ccd781cfa0 | |
parent | ASoC: ak4642: fix a memory leak if failed to initialise AK4642 (diff) | |
download | linux-085efd28b65582fac459359672421a1c479e7db1.tar.xz linux-085efd28b65582fac459359672421a1c479e7db1.zip |
ASoC: da7210: fix a memory leak if failed to initialise da7210 audio codec
da7210 should be kfreed if da7210_init() return error.
This patch also fixes the error handing in the case of snd_soc_register_dai()
fail by adding snd_soc_unregister_codec() in error path.
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/da7210.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sound/soc/codecs/da7210.c b/sound/soc/codecs/da7210.c index 3e42d1e0e601..3c51d6a57523 100644 --- a/sound/soc/codecs/da7210.c +++ b/sound/soc/codecs/da7210.c @@ -499,7 +499,7 @@ static int da7210_init(struct da7210_priv *da7210) ret = snd_soc_register_dai(&da7210_dai); if (ret) { dev_err(codec->dev, "Failed to register DAI: %d\n", ret); - goto init_err; + goto codec_err; } /* FIXME @@ -585,6 +585,8 @@ static int da7210_init(struct da7210_priv *da7210) return ret; +codec_err: + snd_soc_unregister_codec(codec); init_err: kfree(codec->reg_cache); codec->reg_cache = NULL; @@ -612,8 +614,10 @@ static int __devinit da7210_i2c_probe(struct i2c_client *i2c, codec->control_data = i2c; ret = da7210_init(da7210); - if (ret < 0) + if (ret < 0) { pr_err("Failed to initialise da7210 audio codec\n"); + kfree(da7210); + } return ret; } |