]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
ASoC: imx-ssi: fix resource leak
authorAxel Lin <axel.lin@gmail.com>
Thu, 25 Nov 2010 07:13:09 +0000 (15:13 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Thu, 25 Nov 2010 11:09:50 +0000 (11:09 +0000)
Fix imx_ssi_probe() error path and imx_ssi_remove() 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>
sound/soc/imx/imx-ssi.c

index d2d98c75ee8a42b6e840a61307d8a133d54b93a2..390b6ffc26581477599b03efa08ebf9379d6d2b7 100644 (file)
@@ -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);