Commit fe5422fc authored by Mark Brown's avatar Mark Brown

ASoC: Fix leaks in WM8731 probe error handling

Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 096e49d5
...@@ -560,7 +560,8 @@ static int wm8731_register(struct wm8731_priv *wm8731) ...@@ -560,7 +560,8 @@ static int wm8731_register(struct wm8731_priv *wm8731)
if (wm8731_codec) { if (wm8731_codec) {
dev_err(codec->dev, "Another WM8731 is registered\n"); dev_err(codec->dev, "Another WM8731 is registered\n");
return -EINVAL; ret = -EINVAL;
goto err;
} }
mutex_init(&codec->mutex); mutex_init(&codec->mutex);
...@@ -583,8 +584,8 @@ static int wm8731_register(struct wm8731_priv *wm8731) ...@@ -583,8 +584,8 @@ static int wm8731_register(struct wm8731_priv *wm8731)
ret = wm8731_reset(codec); ret = wm8731_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: %d\n", ret);
return ret; goto err;
} }
wm8731_dai.dev = codec->dev; wm8731_dai.dev = codec->dev;
...@@ -610,17 +611,23 @@ static int wm8731_register(struct wm8731_priv *wm8731) ...@@ -610,17 +611,23 @@ static int wm8731_register(struct wm8731_priv *wm8731)
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(&wm8731_dai); ret = snd_soc_register_dai(&wm8731_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); snd_soc_unregister_codec(codec);
return ret; goto err_codec;
} }
return 0; return 0;
err_codec:
snd_soc_unregister_codec(codec);
err:
kfree(wm8731);
return ret;
} }
static void wm8731_unregister(struct wm8731_priv *wm8731) static void wm8731_unregister(struct wm8731_priv *wm8731)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment