ASoC: fix resource leak in error paths
Subsystems (6)
cover ASoC: fix resource leak in error paths
This serial of patches fix resource leak in error paths.
Axel Lin (8):
ASoC: efika-audio-fabric: fix resource leak in efika_fabric_init
error path
ASoC: pcm030-audio-fabric: fix resource leak in pcm030_fabric_init
error path
ASoC: snd-soc-afeb9260: remove unneeded platform_device_del in error
path
ASoC: sam9g20_wm8731: fix resource leak in at91sam9g20ek_init error
path
ASoC: smdk_wm9713: fix resource leak in smdk_init error path
ASoC: simone: fix resource leak in simone_init error path
ASoC: imx-ssi: fix resource leak
ASoC: phycore-ac97: fix resource leak
sound/soc/atmel/sam9g20_wm8731.c | 5 ++++- sound/soc/atmel/snd-soc-afeb9260.c | 1 - sound/soc/ep93xx/simone.c | 18 ++++++++++-------- sound/soc/fsl/efika-audio-fabric.c | 1 + sound/soc/fsl/pcm030-audio-fabric.c | 1 + sound/soc/imx/imx-ssi.c | 15 +++++++++++---- sound/soc/imx/phycore-ac97.c | 28 +++++++++++++++++++++------- sound/soc/samsung/smdk_wm9713.c | 17 ++++++++++------- 8 files changed, 58 insertions(+), 28 deletions(-)
Signature · 1 line
1.7.2
PATCH 1/8 ASoC: efika-audio-fabric: fix resource leak in efika_fabric_init error path
Add missing platform_device_put() if platform_device_add() failed.
--- sound/soc/fsl/efika-audio-fabric.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
sound/soc/fsl/efika-audio-fabric.c +1 -0
@@ -76,6 +76,7 @@ static __init int efika_fabric_init(void) rc =platform_device_add (pdev);if (rc) {pr_err ("efika_fabric_init: platform_device_add() failed\n" ); +platform_device_put (pdev);return -ENODEV ; }return 0 ;
Signature · 1 line
1.7.2
PATCH 2/8 ASoC: pcm030-audio-fabric: fix resource leak in pcm030_fabric_init error path
In reply to Axel LinAdd missing platform_device_put() if platform_device_add() failed.
--- sound/soc/fsl/pcm030-audio-fabric.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
sound/soc/fsl/pcm030-audio-fabric.c +1 -0
@@ -76,6 +76,7 @@ static __init int pcm030_fabric_init(void) rc =platform_device_add (pdev);if (rc) {pr_err ("pcm030_fabric_init: platform_device_add() failed\n" ); +platform_device_put (pdev);return -ENODEV ; }return 0 ;
Signature · 1 line
1.7.2
PATCH 3/8 ASoC: snd-soc-afeb9260: remove unneeded platform_device_del in error path
In reply to Axel LinQuoted 1 line
From
f3b1f9a02fe390b2f12b9097a1d4d9de55618b34Mon Sep 17 00:00:00 2001
From: Axel Lin <[email protected]>
Date: Thu, 25 Nov 2010 10:44:59 +0800
Subject: [PATCH 3/8] ASoC: snd-soc-afeb9260: remove unneeded platform_device_del in error path
--- sound/soc/atmel/snd-soc-afeb9260.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
sound/soc/atmel/snd-soc-afeb9260.c +0 -1
@@ -167,7 +167,6 @@ static int __init afeb9260_soc_init(void)return 0 ; err1: -platform_device_del (afeb9260_snd_device);platform_device_put (afeb9260_snd_device);return err; }
Signature · 1 line
1.7.2
PATCH 4/8 ASoC: sam9g20_wm8731: fix resource leak in at91sam9g20ek_init error path
In reply to Axel LinFix the error path to properly free allocated resources.
--- sound/soc/atmel/sam9g20_wm8731.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
sound/soc/atmel/sam9g20_wm8731.c +4 -1
@@ -240,6 +240,7 @@ static int __init at91sam9g20ek_init(void)if (!at91sam9g20ek_snd_device) {printk (KERN_ERR "ASoC: Platform device allocation failed\n" ); ret = -ENOMEM ; + goto err_mclk; } platform_set_drvdata(at91sam9g20ek_snd_device,
@@ -248,11 +249,13 @@ static int __init at91sam9g20ek_init(void) ret =platform_device_add (at91sam9g20ek_snd_device);if (ret) {printk (KERN_ERR "ASoC: Platform device allocation failed\n" ); -platform_device_put (at91sam9g20ek_snd_device); + goto err_device_add; }return ret; +err_device_add: +platform_device_put (at91sam9g20ek_snd_device); err_mclk:clk_put (mclk); mclk =NULL ;
Signature · 1 line
1.7.2
PATCH 5/8 ASoC: smdk_wm9713: fix resource leak in smdk_init error path
In reply to Axel LinFix the error path to properly free allocated resources.
--- sound/soc/samsung/smdk_wm9713.c | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-)
sound/soc/samsung/smdk_wm9713.c +10 -7
@@ -70,24 +70,27 @@ static int __init smdk_init(void) ret =platform_device_add (smdk_snd_wm9713_device);if (ret) - goto err; + goto err1; smdk_snd_ac97_device =platform_device_alloc ("soc-audio" ,-1 );if (!smdk_snd_ac97_device) { ret = -ENOMEM ; - goto err; + goto err2; }platform_set_drvdata (smdk_snd_ac97_device, &smdk); ret =platform_device_add (smdk_snd_ac97_device); -if (ret) { -platform_device_put (smdk_snd_ac97_device); - goto err; - } +if (ret) + goto err3;return 0 ; -err: + +err3: +platform_device_put (smdk_snd_ac97_device); +err2: +platform_device_del (smdk_snd_wm9713_device); +err1:platform_device_put (smdk_snd_wm9713_device);return ret; }
Signature · 1 line
1.7.2
PATCH 6/8 ASoC: simone: fix resource leak in simone_init error path
In reply to Axel LinFix the error path to properly free allocated resources.
--- sound/soc/ep93xx/simone.c | 18 ++++++++++-------- 1 files changed, 10 insertions(+), 8 deletions(-)
sound/soc/ep93xx/simone.c +10 -8
@@ -54,24 +54,26 @@ static int __init simone_init(void) ret =platform_device_add (simone_snd_ac97_device);if (ret) - goto fail; + goto fail1; simone_snd_device =platform_device_alloc ("soc-audio" ,-1 );if (!simone_snd_device) { ret = -ENOMEM ; - goto fail; + goto fail2; }platform_set_drvdata (simone_snd_device, &snd_soc_simone); ret =platform_device_add (simone_snd_device); -if (ret) { -platform_device_put (simone_snd_device); - goto fail; - } +if (ret) + goto fail3; -return ret; +return 0 ; -fail: +fail3: +platform_device_put (simone_snd_device); +fail2: +platform_device_del (simone_snd_ac97_device); +fail1:platform_device_put (simone_snd_ac97_device);return ret; }
Signature · 1 line
1.7.2
Re: [PATCH 6/8] ASoC: simone: fix resource leak in simone_init error path
Quoted 3 lines · Axel Lin
Fix the error path to properly free allocated resources.
Signed-off-by Axel Lin <[email protected]>
Thanks for catching this.
Quoted 47 lines
--- sound/soc/ep93xx/simone.c | 18 ++++++++++-------- 1 files changed, 10 insertions(+), 8 deletions(-)sound/soc/ep93xx/simone.c +10
-8@@ -54,24 +54,26 @@ static int __init simone_init(void) ret =platform_device_add (simone_snd_ac97_device);if (ret) - goto fail; + goto fail1; simone_snd_device =platform_device_alloc ("soc-audio" ,-1 );if (!simone_snd_device) { ret = -ENOMEM ; - goto fail; + goto fail2; }platform_set_drvdata (simone_snd_device, &snd_soc_simone); ret =platform_device_add (simone_snd_device); -if (ret) { -platform_device_put (simone_snd_device); - goto fail; - } +if (ret) + goto fail3; -return ret; +return 0 ; -fail: +fail3: +platform_device_put (simone_snd_device); +fail2: +platform_device_del (simone_snd_ac97_device); +fail1:platform_device_put (simone_snd_ac97_device);return ret; }Signature · 1 line
1.7.2
PATCH 7/8 ASoC: imx-ssi: fix resource leak
In reply to Axel LinFix imx_ssi_probe() error path and imx_ssi_remove() to properly free allocated resources.
--- sound/soc/imx/imx-ssi.c | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-)
sound/soc/imx/imx-ssi.c +11 -4
@@ -679,8 +679,11 @@ static int imx_ssi_probe(struct platform_device *pdev) } ssi->soc_platform_pdev_fiq =platform_device_alloc ("imx-fiq-pcm-audio" , pdev->id); -if (!ssi->soc_platform_pdev_fiq) +if (!ssi->soc_platform_pdev_fiq) { + ret = -ENOMEM ; goto failed_pdev_fiq_alloc; + } +platform_set_drvdata (ssi->soc_platform_pdev_fiq, ssi); ret =platform_device_add (ssi->soc_platform_pdev_fiq);if (ret) {
@@ -689,8 +692,11 @@ static int imx_ssi_probe(struct platform_device *pdev) } ssi->soc_platform_pdev =platform_device_alloc ("imx-pcm-audio" , pdev->id); -if (!ssi->soc_platform_pdev) +if (!ssi->soc_platform_pdev) { + ret = -ENOMEM ; goto failed_pdev_alloc; + } +platform_set_drvdata (ssi->soc_platform_pdev, ssi); ret =platform_device_add (ssi->soc_platform_pdev);if (ret) {
@@ -703,6 +709,7 @@ static int imx_ssi_probe(struct platform_device *pdev) failed_pdev_add:platform_device_put (ssi->soc_platform_pdev); failed_pdev_alloc: +platform_device_del (ssi->soc_platform_pdev_fiq); failed_pdev_fiq_add:platform_device_put (ssi->soc_platform_pdev_fiq); failed_pdev_fiq_alloc:
@@ -726,8 +733,8 @@ static int __devexit imx_ssi_remove(struct platform_device *pdev)struct resource *res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );struct imx_ssi *ssi =platform_get_drvdata (pdev); -platform_device_del (ssi->soc_platform_pdev); -platform_device_put (ssi->soc_platform_pdev); +platform_device_unregister (ssi->soc_platform_pdev); +platform_device_unregister (ssi->soc_platform_pdev_fiq);snd_soc_unregister_dai (&pdev->dev);
Signature · 1 line
1.7.2
Re: [PATCH 7/8] ASoC: imx-ssi: fix resource leak
Quoted 4 lines · Axel Lin
Fix
imx_ssi_probe()error path andimx_ssi_remove()to properly free allocated resources.Signed-off-by Axel Lin <[email protected]>
Quoted 59 lines
--- sound/soc/imx/imx-ssi.c | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-)sound/soc/imx/imx-ssi.c +11
-4@@ -679,8 +679,11 @@ static int imx_ssi_probe(struct platform_device *pdev) } ssi->soc_platform_pdev_fiq =platform_device_alloc ("imx-fiq-pcm-audio" , pdev->id); -if (!ssi->soc_platform_pdev_fiq) +if (!ssi->soc_platform_pdev_fiq) { + ret = -ENOMEM ; goto failed_pdev_fiq_alloc; + } +platform_set_drvdata (ssi->soc_platform_pdev_fiq, ssi); ret =platform_device_add (ssi->soc_platform_pdev_fiq);if (ret) {@@ -689,8 +692,11 @@ static int imx_ssi_probe(struct platform_device *pdev) } ssi->soc_platform_pdev =platform_device_alloc ("imx-pcm-audio" , pdev->id); -if (!ssi->soc_platform_pdev) +if (!ssi->soc_platform_pdev) { + ret = -ENOMEM ; goto failed_pdev_alloc; + } +platform_set_drvdata (ssi->soc_platform_pdev, ssi); ret =platform_device_add (ssi->soc_platform_pdev);if (ret) {@@ -703,6 +709,7 @@ static int imx_ssi_probe(struct platform_device *pdev) failed_pdev_add:platform_device_put (ssi->soc_platform_pdev); failed_pdev_alloc: +platform_device_del (ssi->soc_platform_pdev_fiq); failed_pdev_fiq_add:platform_device_put (ssi->soc_platform_pdev_fiq); failed_pdev_fiq_alloc:@@ -726,8 +733,8 @@ static int __devexit imx_ssi_remove(struct platform_device *pdev)struct resource *res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );struct imx_ssi *ssi =platform_get_drvdata (pdev); -platform_device_del (ssi->soc_platform_pdev); -platform_device_put (ssi->soc_platform_pdev); +platform_device_unregister (ssi->soc_platform_pdev); +platform_device_unregister (ssi->soc_platform_pdev_fiq);snd_soc_unregister_dai (&pdev->dev);Signature · 1 line
1.7.2
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
PATCH 8/8 ASoC: phycore-ac97: fix resource leak
In reply to Axel LinFix imx_phycore_init() error path and imx_phycore_exit() to properly free allocated resources.
--- sound/soc/imx/phycore-ac97.c | 28 +++++++++++++++++++++------- 1 files changed, 21 insertions(+), 7 deletions(-)
sound/soc/imx/phycore-ac97.c +21 -7
@@ -42,6 +42,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 )
@@ -52,29 +53,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);
Signature · 1 line
1.7.2
Re: [PATCH 8/8] ASoC: phycore-ac97: fix resource leak
Quoted 4 lines · Axel Lin
Fix
imx_phycore_init()error path andimx_phycore_exit()to properly free allocated resources.Signed-off-by Axel Lin <[email protected]>
Quoted 72 lines
--- sound/soc/imx/phycore-ac97.c | 28 +++++++++++++++++++++------- 1 files changed, 21 insertions(+), 7 deletions(-)sound/soc/imx/phycore-ac97.c +21
-7@@ -42,6 +42,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 )@@ -52,29 +53,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);Signature · 1 line
1.7.2
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Quoted 16 lines · Axel Lin
This serial of patches fix resource leak in error paths.
Axel Lin (8):
ASoC: efika-audio-fabric: fix resource leak inefika_fabric_init
error path
ASoC: pcm030-audio-fabric: fix resource leak inpcm030_fabric_init
error path
ASoC: snd-soc-afeb9260: remove unneededplatform_device_delin error
path
ASoC:sam9g20_wm8731: fix resource leak inat91sam9g20ek_initerror
path
ASoC:smdk_wm9713: fix resource leak insmdk_initerror path
ASoC: simone: fix resource leak insimone_initerror path
ASoC: imx-ssi: fix resource leak
ASoC: phycore-ac97: fix resource leak
Quoted 10 lines
sound/soc/atmel/sam9g20_wm8731.c | 5 ++++- sound/soc/atmel/snd-soc-afeb9260.c | 1 - sound/soc/ep93xx/simone.c | 18 ++++++++++-------- sound/soc/fsl/efika-audio-fabric.c | 1 + sound/soc/fsl/pcm030-audio-fabric.c | 1 + sound/soc/imx/imx-ssi.c | 15 +++++++++++---- sound/soc/imx/phycore-ac97.c | 28 +++++++++++++++++++++------- sound/soc/samsung/smdk_wm9713.c | 17 ++++++++++------- 8 files changed, 58 insertions(+), 28 deletions(-)
All
Signature · 3 lines
Freelance Developer, SlimLogic Ltd ASoC and Voltage Regulator Maintainer. http://www.slimlogic.co.uk
Quoted 1 line · Axel Lin
This serial of patches fix resource leak in error paths.
All applied, thanks - thanks for taking the time to do so many cleanups recently, it's appreciated.