diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-07-05 10:18:01 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-07-05 10:18:01 -0400 |
commit | fe5422fc4ac221910083e603eb2a873280a9bd37 (patch) | |
tree | 3176ed55d69d9989937437e625aaf0f6b85c1159 /sound/soc/codecs/wm8731.c | |
parent | 096e49d5e6f7bd93395e7ddf7e0239e1644d0505 (diff) |
ASoC: Fix leaks in WM8731 probe error handling
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/wm8731.c')
-rw-r--r-- | sound/soc/codecs/wm8731.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index d7f4788f7ace..dfbc1bb375f4 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c | |||
@@ -560,7 +560,8 @@ static int wm8731_register(struct wm8731_priv *wm8731) | |||
560 | 560 | ||
561 | if (wm8731_codec) { | 561 | if (wm8731_codec) { |
562 | dev_err(codec->dev, "Another WM8731 is registered\n"); | 562 | dev_err(codec->dev, "Another WM8731 is registered\n"); |
563 | return -EINVAL; | 563 | ret = -EINVAL; |
564 | goto err; | ||
564 | } | 565 | } |
565 | 566 | ||
566 | mutex_init(&codec->mutex); | 567 | mutex_init(&codec->mutex); |
@@ -583,8 +584,8 @@ static int wm8731_register(struct wm8731_priv *wm8731) | |||
583 | 584 | ||
584 | ret = wm8731_reset(codec); | 585 | ret = wm8731_reset(codec); |
585 | if (ret < 0) { | 586 | if (ret < 0) { |
586 | dev_err(codec->dev, "Failed to issue reset\n"); | 587 | dev_err(codec->dev, "Failed to issue reset: %d\n", ret); |
587 | return ret; | 588 | goto err; |
588 | } | 589 | } |
589 | 590 | ||
590 | wm8731_dai.dev = codec->dev; | 591 | wm8731_dai.dev = codec->dev; |
@@ -610,17 +611,23 @@ static int wm8731_register(struct wm8731_priv *wm8731) | |||
610 | ret = snd_soc_register_codec(codec); | 611 | ret = snd_soc_register_codec(codec); |
611 | if (ret != 0) { | 612 | if (ret != 0) { |
612 | dev_err(codec->dev, "Failed to register codec: %d\n", ret); | 613 | dev_err(codec->dev, "Failed to register codec: %d\n", ret); |
613 | return ret; | 614 | goto err; |
614 | } | 615 | } |
615 | 616 | ||
616 | ret = snd_soc_register_dai(&wm8731_dai); | 617 | ret = snd_soc_register_dai(&wm8731_dai); |
617 | if (ret != 0) { | 618 | if (ret != 0) { |
618 | dev_err(codec->dev, "Failed to register DAI: %d\n", ret); | 619 | dev_err(codec->dev, "Failed to register DAI: %d\n", ret); |
619 | snd_soc_unregister_codec(codec); | 620 | snd_soc_unregister_codec(codec); |
620 | return ret; | 621 | goto err_codec; |
621 | } | 622 | } |
622 | 623 | ||
623 | return 0; | 624 | return 0; |
625 | |||
626 | err_codec: | ||
627 | snd_soc_unregister_codec(codec); | ||
628 | err: | ||
629 | kfree(wm8731); | ||
630 | return ret; | ||
624 | } | 631 | } |
625 | 632 | ||
626 | static void wm8731_unregister(struct wm8731_priv *wm8731) | 633 | static void wm8731_unregister(struct wm8731_priv *wm8731) |