Skip to contentSkip to conversation

rtc: rtc-sh - fix a memory leak

PATCH In review Axel Lin 2 participants 2 messages Nov 8, 2010 Real time clock (RTC)

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 rtc: rtc-sh - fix a memory leak

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.

---
 drivers/rtc/rtc-sh.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/rtc/rtc-sh.c +2 -2
index 5efbd59..06e41ed 100644
@@ -761,7 +761,7 @@ err_unmap:
 	clk_put(rtc->clk);
 	iounmap(rtc->regbase);
 err_badmap:
-	release_resource(rtc->res);
+	release_mem_region(rtc->res->start, rtc->regsize);
 err_badres:
 	kfree(rtc);
 
@@ -786,7 +786,7 @@ static int __exit sh_rtc_remove(struct platform_device *pdev)
 	}
 
 	iounmap(rtc->regbase);
-	release_resource(rtc->res);
+	release_mem_region(rtc->res->start, rtc->regsize);
 
 	clk_disable(rtc->clk);
 	clk_put(rtc->clk);
Signature · 1 line
1.7.2
#1 lore raw
Quoted 5 lines · Axel Lin

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.

Good catch! Applied, thanks.