drivers/rtc/rtc-omap.c: fix a memory leak
authorAxel Lin <[email protected]>
Thu, 13 Jan 2011 01:00:05 +0000 (17:00 -0800)
committerLinus Torvalds <[email protected]>
Thu, 13 Jan 2011 16:03:12 +0000 (08:03 -0800)
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 <[email protected]>
Cc: Alessandro Zummo <[email protected]>
Cc: Sekhar Nori <[email protected]>
Cc: Kevin Hilman <[email protected]>
Cc: Tony Lindgren <[email protected]>
Acked-by: Mark A. Greer <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
drivers/rtc/rtc-omap.c

index 73377b0d65dabe5f37d241e748c99ed4507ee45e..e72b523c79a5465107a18687752190ac0fe4a03e 100644 (file)
@@ -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;
 }