diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-07-05 10:47:03 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-07-05 10:47:03 -0400 |
commit | 1a01417e85846e42e939a345a294e8ae2287cc1f (patch) | |
tree | b9adad9d424617b44d82c885f83b6aa661a81834 /sound/soc/codecs/wm8960.c | |
parent | fe5422fc4ac221910083e603eb2a873280a9bd37 (diff) |
ASoC: Fix WM8960 leaks on probe failure
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/wm8960.c')
-rw-r--r-- | sound/soc/codecs/wm8960.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c index b7894d6dffc0..d1769e6c0c44 100644 --- a/sound/soc/codecs/wm8960.c +++ b/sound/soc/codecs/wm8960.c | |||
@@ -810,7 +810,8 @@ static int wm8960_register(struct wm8960_priv *wm8960) | |||
810 | 810 | ||
811 | if (wm8960_codec) { | 811 | if (wm8960_codec) { |
812 | dev_err(codec->dev, "Another WM8960 is registered\n"); | 812 | dev_err(codec->dev, "Another WM8960 is registered\n"); |
813 | return -EINVAL; | 813 | ret = -EINVAL; |
814 | goto err; | ||
814 | } | 815 | } |
815 | 816 | ||
816 | if (!pdata) { | 817 | if (!pdata) { |
@@ -843,7 +844,7 @@ static int wm8960_register(struct wm8960_priv *wm8960) | |||
843 | ret = wm8960_reset(codec); | 844 | ret = wm8960_reset(codec); |
844 | if (ret < 0) { | 845 | if (ret < 0) { |
845 | dev_err(codec->dev, "Failed to issue reset\n"); | 846 | dev_err(codec->dev, "Failed to issue reset\n"); |
846 | return ret; | 847 | goto err; |
847 | } | 848 | } |
848 | 849 | ||
849 | wm8960_dai.dev = codec->dev; | 850 | wm8960_dai.dev = codec->dev; |
@@ -877,17 +878,22 @@ static int wm8960_register(struct wm8960_priv *wm8960) | |||
877 | ret = snd_soc_register_codec(codec); | 878 | ret = snd_soc_register_codec(codec); |
878 | if (ret != 0) { | 879 | if (ret != 0) { |
879 | dev_err(codec->dev, "Failed to register codec: %d\n", ret); | 880 | dev_err(codec->dev, "Failed to register codec: %d\n", ret); |
880 | return ret; | 881 | goto err; |
881 | } | 882 | } |
882 | 883 | ||
883 | ret = snd_soc_register_dai(&wm8960_dai); | 884 | ret = snd_soc_register_dai(&wm8960_dai); |
884 | if (ret != 0) { | 885 | if (ret != 0) { |
885 | dev_err(codec->dev, "Failed to register DAI: %d\n", ret); | 886 | dev_err(codec->dev, "Failed to register DAI: %d\n", ret); |
886 | snd_soc_unregister_codec(codec); | 887 | goto err_codec; |
887 | return ret; | ||
888 | } | 888 | } |
889 | 889 | ||
890 | return 0; | 890 | return 0; |
891 | |||
892 | err_codec: | ||
893 | snd_soc_unregister_codec(codec); | ||
894 | err: | ||
895 | kfree(wm8960); | ||
896 | return ret; | ||
891 | } | 897 | } |
892 | 898 | ||
893 | static void wm8960_unregister(struct wm8960_priv *wm8960) | 899 | static void wm8960_unregister(struct wm8960_priv *wm8960) |