drivers/rtc/rtc-spear.c: fix use-after-free in spear_rtc_remove()
authorDevendra Naga <[email protected]>
Wed, 11 Jul 2012 21:01:53 +0000 (14:01 -0700)
committerLinus Torvalds <[email protected]>
Wed, 11 Jul 2012 23:04:41 +0000 (16:04 -0700)
`config' is freed and is then used in the rtc_device_unregister() call,
causing a kernel panic.

Signed-off-by: Devendra Naga <[email protected]>
Reviewed-by: Viresh Kumar <[email protected]>
Cc: Alessandro Zummo <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
drivers/rtc/rtc-spear.c

index 1f76320e545b1cf15d563cc8996b8eed7122f14a..e2785479113ca06648949d6c6a78adee92c78367 100644 (file)
@@ -458,12 +458,12 @@ static int __devexit spear_rtc_remove(struct platform_device *pdev)
        clk_disable(config->clk);
        clk_put(config->clk);
        iounmap(config->ioaddr);
-       kfree(config);
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        if (res)
                release_mem_region(res->start, resource_size(res));
        platform_set_drvdata(pdev, NULL);
        rtc_device_unregister(config->rtc);
+       kfree(config);
 
        return 0;
 }