mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 16:24:13 +08:00
ASoC: Fix WM8960 leaks on probe failure
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
parent
fe5422fc4a
commit
1a01417e85
@ -810,7 +810,8 @@ static int wm8960_register(struct wm8960_priv *wm8960)
|
|||||||
|
|
||||||
if (wm8960_codec) {
|
if (wm8960_codec) {
|
||||||
dev_err(codec->dev, "Another WM8960 is registered\n");
|
dev_err(codec->dev, "Another WM8960 is registered\n");
|
||||||
return -EINVAL;
|
ret = -EINVAL;
|
||||||
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pdata) {
|
if (!pdata) {
|
||||||
@ -843,7 +844,7 @@ static int wm8960_register(struct wm8960_priv *wm8960)
|
|||||||
ret = wm8960_reset(codec);
|
ret = wm8960_reset(codec);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(codec->dev, "Failed to issue reset\n");
|
dev_err(codec->dev, "Failed to issue reset\n");
|
||||||
return ret;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
wm8960_dai.dev = codec->dev;
|
wm8960_dai.dev = codec->dev;
|
||||||
@ -877,17 +878,22 @@ static int wm8960_register(struct wm8960_priv *wm8960)
|
|||||||
ret = snd_soc_register_codec(codec);
|
ret = snd_soc_register_codec(codec);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
dev_err(codec->dev, "Failed to register codec: %d\n", ret);
|
dev_err(codec->dev, "Failed to register codec: %d\n", ret);
|
||||||
return ret;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = snd_soc_register_dai(&wm8960_dai);
|
ret = snd_soc_register_dai(&wm8960_dai);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
dev_err(codec->dev, "Failed to register DAI: %d\n", ret);
|
dev_err(codec->dev, "Failed to register DAI: %d\n", ret);
|
||||||
snd_soc_unregister_codec(codec);
|
goto err_codec;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
err_codec:
|
||||||
|
snd_soc_unregister_codec(codec);
|
||||||
|
err:
|
||||||
|
kfree(wm8960);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wm8960_unregister(struct wm8960_priv *wm8960)
|
static void wm8960_unregister(struct wm8960_priv *wm8960)
|
||||||
|
Loading…
Reference in New Issue
Block a user