mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] rtc: rtc-omap - fix a memory leak
@ 2010-11-10  2:37 Axel Lin
  2010-11-11 20:20 ` Mark A. Greer
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2010-11-10  2:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: Mark A. Greer, Alessandro Zummo, rtc-linux, Andrew Morton

request_mem_region() will call kzalloc to allocate memory for struct resource.
release_resource() unregisters the resource but does not free the allocated
memory, thus use release_mem_region() instead to fix the memory leak.

Also add a missing iounmap() in omap_rtc_remove().

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/rtc/rtc-omap.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index 73377b0..e72b523 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -429,13 +429,14 @@ fail1:
 fail0:
 	iounmap(rtc_base);
 fail:
-	release_resource(mem);
+	release_mem_region(mem->start, resource_size(mem));
 	return -EIO;
 }
 
 static int __exit omap_rtc_remove(struct platform_device *pdev)
 {
 	struct rtc_device	*rtc = platform_get_drvdata(pdev);
+	struct resource		*mem = dev_get_drvdata(&rtc->dev);
 
 	device_init_wakeup(&pdev->dev, 0);
 
@@ -447,8 +448,9 @@ static int __exit omap_rtc_remove(struct platform_device *pdev)
 	if (omap_rtc_timer != omap_rtc_alarm)
 		free_irq(omap_rtc_alarm, rtc);
 
-	release_resource(dev_get_drvdata(&rtc->dev));
 	rtc_device_unregister(rtc);
+	iounmap(rtc_base);
+	release_mem_region(mem->start, resource_size(mem));
 	return 0;
 }
 
-- 
1.7.2




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

* Re: [PATCH] rtc: rtc-omap - fix a memory leak
  2010-11-10  2:37 [PATCH] rtc: rtc-omap - fix a memory leak Axel Lin
@ 2010-11-11 20:20 ` Mark A. Greer
  0 siblings, 0 replies; 2+ messages in thread
From: Mark A. Greer @ 2010-11-11 20:20 UTC (permalink / raw)
  To: Axel Lin
  Cc: linux-kernel, Mark A. Greer, Alessandro Zummo, rtc-linux, Andrew Morton

On Wed, Nov 10, 2010 at 10:37:20AM +0800, Axel Lin wrote:
> request_mem_region() will call kzalloc to allocate memory for struct resource.
> release_resource() unregisters the resource but does not free the allocated
> memory, thus use release_mem_region() instead to fix the memory leak.
> 
> Also add a missing iounmap() in omap_rtc_remove().
> 
> Signed-off-by: Axel Lin <axel.lin@gmail.com>

FWIW,

Acked-by: Mark A. Greer <mgreer@mvista.com>

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

end of thread, other threads:[~2010-11-11 20:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-10  2:37 [PATCH] rtc: rtc-omap - fix a memory leak Axel Lin
2010-11-11 20:20 ` Mark A. Greer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®