arm: plat-omap: iommu: fix request_mem_region() error path
authorAaro Koskinen <Aaro.Koskinen@nokia.com>
Mon, 14 Mar 2011 12:28:32 +0000 (12:28 +0000)
committerTony Lindgren <tony@atomide.com>
Mon, 14 Mar 2011 18:14:34 +0000 (11:14 -0700)
request_mem_region() error exit will leak ioremapped memory. Fix this
by moving the ioremap() after request_mem_region(), which is the proper
order to do this anyway.

Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
arch/arm/plat-omap/iommu.c

index e3eb0380090aa0a0a6db382b823c7e538b8fd453..8a51fd58f656e15f6f1fa7d51eb0501e18143149 100644 (file)
@@ -982,11 +982,6 @@ static int __devinit omap_iommu_probe(struct platform_device *pdev)
                err = -ENODEV;
                goto err_mem;
        }
-       obj->regbase = ioremap(res->start, resource_size(res));
-       if (!obj->regbase) {
-               err = -ENOMEM;
-               goto err_mem;
-       }
 
        res = request_mem_region(res->start, resource_size(res),
                                 dev_name(&pdev->dev));
@@ -995,6 +990,12 @@ static int __devinit omap_iommu_probe(struct platform_device *pdev)
                goto err_mem;
        }
 
+       obj->regbase = ioremap(res->start, resource_size(res));
+       if (!obj->regbase) {
+               err = -ENOMEM;
+               goto err_ioremap;
+       }
+
        irq = platform_get_irq(pdev, 0);
        if (irq < 0) {
                err = -ENODEV;
@@ -1023,8 +1024,9 @@ static int __devinit omap_iommu_probe(struct platform_device *pdev)
 err_pgd:
        free_irq(irq, obj);
 err_irq:
-       release_mem_region(res->start, resource_size(res));
        iounmap(obj->regbase);
+err_ioremap:
+       release_mem_region(res->start, resource_size(res));
 err_mem:
        clk_put(obj->clk);
 err_clk: