提交 085efd28 编写于 作者: A Axel Lin 提交者: Mark Brown

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: NAxel Lin <axel.lin@gmail.com>
Acked-by: NLiam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
上级 7bcaad91
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册