[media] V4L: omap1_camera: fix use after free
authorMathias Krause <minipli@googlemail.com>
Sun, 30 Jan 2011 10:05:58 +0000 (07:05 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 21 Mar 2011 23:32:14 +0000 (20:32 -0300)
Even though clk_put() is a no-op on most architectures it is not for
some ARM implementations. To not fail on those, release the clock timer
before freeing the surrounding structure.

This bug was spotted by the semantic patch tool coccinelle using the
script found at scripts/coccinelle/free/kfree.cocci.

More information about semantic patching is available at
http://coccinelle.lip6.fr/

Signed-off-by: Mathias Krause <minipli@googlemail.com>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/omap1_camera.c

index 0a2fb2bfdbfbbfeee180ee521495452fdc29234e..9ed1513122c10b2bd1f583f008ab63600dd39afa 100644 (file)
@@ -1664,10 +1664,10 @@ static int __exit omap1_cam_remove(struct platform_device *pdev)
        res = pcdev->res;
        release_mem_region(res->start, resource_size(res));
 
-       kfree(pcdev);
-
        clk_put(pcdev->clk);
 
+       kfree(pcdev);
+
        dev_info(&pdev->dev, "OMAP1 Camera Interface driver unloaded\n");
 
        return 0;