linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm: plat-omap: iommu: fix request_mem_region() error path
@ 2011-03-14 12:28 Aaro Koskinen
  2011-03-14 12:50 ` Hiroshi DOYU
  0 siblings, 1 reply; 3+ messages in thread
From: Aaro Koskinen @ 2011-03-14 12:28 UTC (permalink / raw)
  To: tony, Hiroshi.DOYU, linux-omap, linux-arm-kernel; +Cc: Aaro Koskinen

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>
---
 arch/arm/plat-omap/iommu.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/arm/plat-omap/iommu.c b/arch/arm/plat-omap/iommu.c
index b1107c0..50be5e7 100644
--- a/arch/arm/plat-omap/iommu.c
+++ b/arch/arm/plat-omap/iommu.c
@@ -957,11 +957,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));
@@ -970,6 +965,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;
@@ -998,8 +999,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:
-- 
1.5.6.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] arm: plat-omap: iommu: fix request_mem_region() error path
  2011-03-14 12:28 [PATCH] arm: plat-omap: iommu: fix request_mem_region() error path Aaro Koskinen
@ 2011-03-14 12:50 ` Hiroshi DOYU
  2011-03-14 18:12   ` Tony Lindgren
  0 siblings, 1 reply; 3+ messages in thread
From: Hiroshi DOYU @ 2011-03-14 12:50 UTC (permalink / raw)
  To: tony, aaro.koskinen; +Cc: linux-omap, linux-arm-kernel

Hi Aaro,

From: Aaro Koskinen <aaro.koskinen@nokia.com>
Subject: [PATCH] arm: plat-omap: iommu: fix request_mem_region() error path
Date: Mon, 14 Mar 2011 14:28:32 +0200

> 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>
> ---
>  arch/arm/plat-omap/iommu.c |   14 ++++++++------
>  1 files changed, 8 insertions(+), 6 deletions(-)

True. Thank you for catching this.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] arm: plat-omap: iommu: fix request_mem_region() error path
  2011-03-14 12:50 ` Hiroshi DOYU
@ 2011-03-14 18:12   ` Tony Lindgren
  0 siblings, 0 replies; 3+ messages in thread
From: Tony Lindgren @ 2011-03-14 18:12 UTC (permalink / raw)
  To: Hiroshi DOYU; +Cc: aaro.koskinen, linux-omap, linux-arm-kernel

* Hiroshi DOYU <Hiroshi.DOYU@nokia.com> [110314 05:50]:
> Hi Aaro,
> 
> From: Aaro Koskinen <aaro.koskinen@nokia.com>
> Subject: [PATCH] arm: plat-omap: iommu: fix request_mem_region() error path
> Date: Mon, 14 Mar 2011 14:28:32 +0200
> 
> > 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>
> > ---
> >  arch/arm/plat-omap/iommu.c |   14 ++++++++------
> >  1 files changed, 8 insertions(+), 6 deletions(-)
> 
> True. Thank you for catching this.

Applying.

Tony

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-03-14 18:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-14 12:28 [PATCH] arm: plat-omap: iommu: fix request_mem_region() error path Aaro Koskinen
2011-03-14 12:50 ` Hiroshi DOYU
2011-03-14 18:12   ` Tony Lindgren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).