Skip to content

Commit

Permalink
rtc: rtc-sh - fix a memory leak
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
  • Loading branch information
Axel Lin authored and Paul Mundt committed Nov 8, 2010
1 parent 151f52f commit 899be96
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/rtc/rtc-sh.c
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ static int __init sh_rtc_probe(struct platform_device *pdev)
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);

Expand All @@ -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);
Expand Down

0 comments on commit 899be96

Please sign in to comment.