mirror of
https://github.com/torvalds/linux.git
synced 2024-11-05 11:32:04 +00:00
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>
This commit is contained in:
parent
ac8f924af5
commit
09de953334
@ -43,6 +43,7 @@ static struct snd_soc_card imx_phycore = {
|
||||
.num_links = ARRAY_SIZE(imx_phycore_dai_ac97),
|
||||
};
|
||||
|
||||
static struct platform_device *imx_phycore_snd_ac97_device;
|
||||
static struct platform_device *imx_phycore_snd_device;
|
||||
|
||||
static int __init imx_phycore_init(void)
|
||||
@ -53,29 +54,42 @@ static int __init imx_phycore_init(void)
|
||||
/* return happy. We might run on a totally different machine */
|
||||
return 0;
|
||||
|
||||
imx_phycore_snd_device = platform_device_alloc("soc-audio", -1);
|
||||
if (!imx_phycore_snd_device)
|
||||
imx_phycore_snd_ac97_device = platform_device_alloc("soc-audio", -1);
|
||||
if (!imx_phycore_snd_ac97_device)
|
||||
return -ENOMEM;
|
||||
|
||||
platform_set_drvdata(imx_phycore_snd_device, &imx_phycore);
|
||||
ret = platform_device_add(imx_phycore_snd_device);
|
||||
platform_set_drvdata(imx_phycore_snd_ac97_device, &imx_phycore);
|
||||
ret = platform_device_add(imx_phycore_snd_ac97_device);
|
||||
if (ret)
|
||||
goto fail1;
|
||||
|
||||
imx_phycore_snd_device = platform_device_alloc("wm9712-codec", -1);
|
||||
if (!imx_phycore_snd_device)
|
||||
return -ENOMEM;
|
||||
if (!imx_phycore_snd_device) {
|
||||
ret = -ENOMEM;
|
||||
goto fail2;
|
||||
}
|
||||
ret = platform_device_add(imx_phycore_snd_device);
|
||||
|
||||
if (ret) {
|
||||
printk(KERN_ERR "ASoC: Platform device allocation failed\n");
|
||||
platform_device_put(imx_phycore_snd_device);
|
||||
goto fail3;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
fail3:
|
||||
platform_device_put(imx_phycore_snd_device);
|
||||
fail2:
|
||||
platform_device_del(imx_phycore_snd_ac97_device);
|
||||
fail1:
|
||||
platform_device_put(imx_phycore_snd_ac97_device);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void __exit imx_phycore_exit(void)
|
||||
{
|
||||
platform_device_unregister(imx_phycore_snd_device);
|
||||
platform_device_unregister(imx_phycore_snd_ac97_device);
|
||||
}
|
||||
|
||||
late_initcall(imx_phycore_init);
|
||||
|
Loading…
Reference in New Issue
Block a user