diff options
author | Axel Lin <axel.lin@gmail.com> | 2010-11-25 02:14:03 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-11-25 06:10:11 -0500 |
commit | 09de9533348632fbbf32ce618f669882aa718817 (patch) | |
tree | 79630544789dadefefdd911fa9407a9f1a948c95 /sound/soc/imx | |
parent | ac8f924af555573e29b126ac5cef4fdd122ae517 (diff) |
ASoC: phycore-ac97: fix resource leak
Fix imx_phycore_init() error path and imx_phycore_exit() to properly free
allocated resources.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/imx')
-rw-r--r-- | sound/soc/imx/phycore-ac97.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/sound/soc/imx/phycore-ac97.c b/sound/soc/imx/phycore-ac97.c index 39f23734781a..9eabc28667e6 100644 --- a/sound/soc/imx/phycore-ac97.c +++ b/sound/soc/imx/phycore-ac97.c | |||
@@ -43,6 +43,7 @@ static struct snd_soc_card imx_phycore = { | |||
43 | .num_links = ARRAY_SIZE(imx_phycore_dai_ac97), | 43 | .num_links = ARRAY_SIZE(imx_phycore_dai_ac97), |
44 | }; | 44 | }; |
45 | 45 | ||
46 | static struct platform_device *imx_phycore_snd_ac97_device; | ||
46 | static struct platform_device *imx_phycore_snd_device; | 47 | static struct platform_device *imx_phycore_snd_device; |
47 | 48 | ||
48 | static int __init imx_phycore_init(void) | 49 | static int __init imx_phycore_init(void) |
@@ -53,29 +54,42 @@ static int __init imx_phycore_init(void) | |||
53 | /* return happy. We might run on a totally different machine */ | 54 | /* return happy. We might run on a totally different machine */ |
54 | return 0; | 55 | return 0; |
55 | 56 | ||
56 | imx_phycore_snd_device = platform_device_alloc("soc-audio", -1); | 57 | imx_phycore_snd_ac97_device = platform_device_alloc("soc-audio", -1); |
57 | if (!imx_phycore_snd_device) | 58 | if (!imx_phycore_snd_ac97_device) |
58 | return -ENOMEM; | 59 | return -ENOMEM; |
59 | 60 | ||
60 | platform_set_drvdata(imx_phycore_snd_device, &imx_phycore); | 61 | platform_set_drvdata(imx_phycore_snd_ac97_device, &imx_phycore); |
61 | ret = platform_device_add(imx_phycore_snd_device); | 62 | ret = platform_device_add(imx_phycore_snd_ac97_device); |
63 | if (ret) | ||
64 | goto fail1; | ||
62 | 65 | ||
63 | imx_phycore_snd_device = platform_device_alloc("wm9712-codec", -1); | 66 | imx_phycore_snd_device = platform_device_alloc("wm9712-codec", -1); |
64 | if (!imx_phycore_snd_device) | 67 | if (!imx_phycore_snd_device) { |
65 | return -ENOMEM; | 68 | ret = -ENOMEM; |
69 | goto fail2; | ||
70 | } | ||
66 | ret = platform_device_add(imx_phycore_snd_device); | 71 | ret = platform_device_add(imx_phycore_snd_device); |
67 | 72 | ||
68 | if (ret) { | 73 | if (ret) { |
69 | printk(KERN_ERR "ASoC: Platform device allocation failed\n"); | 74 | printk(KERN_ERR "ASoC: Platform device allocation failed\n"); |
70 | platform_device_put(imx_phycore_snd_device); | 75 | goto fail3; |
71 | } | 76 | } |
72 | 77 | ||
78 | return 0; | ||
79 | |||
80 | fail3: | ||
81 | platform_device_put(imx_phycore_snd_device); | ||
82 | fail2: | ||
83 | platform_device_del(imx_phycore_snd_ac97_device); | ||
84 | fail1: | ||
85 | platform_device_put(imx_phycore_snd_ac97_device); | ||
73 | return ret; | 86 | return ret; |
74 | } | 87 | } |
75 | 88 | ||
76 | static void __exit imx_phycore_exit(void) | 89 | static void __exit imx_phycore_exit(void) |
77 | { | 90 | { |
78 | platform_device_unregister(imx_phycore_snd_device); | 91 | platform_device_unregister(imx_phycore_snd_device); |
92 | platform_device_unregister(imx_phycore_snd_ac97_device); | ||
79 | } | 93 | } |
80 | 94 | ||
81 | late_initcall(imx_phycore_init); | 95 | late_initcall(imx_phycore_init); |