[media] drivers/media/video: add missing kfree
authorJulia Lawall <julia@diku.dk>
Mon, 4 Jul 2011 14:11:42 +0000 (11:11 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Wed, 27 Jul 2011 20:55:55 +0000 (17:55 -0300)
Free the recently allocated qcam in each case.

The semantic match that finds this problem is as follows:

// <smpl>
@r@
identifier x;
@@

kfree(x)

@@
identifier r.x;
expression E1!=0,E2,E3,E4;
statement S;
@@

(
if (<+...x...+>) S
|
if (...) { ... when != kfree(x)
               when != if (...) { ... kfree(x); ... }
               when != x = E3
* return E1;
}
... when != x = E2
if (...) { ... when != x = E4
 kfree(x); ... return ...; }
)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/bw-qcam.c
drivers/media/video/c-qcam.c

index 2fc998e9b2f7cb96d13499545ee98312abe9ff59..f09df9dffaae50d3db2ac887757e53d4fb2ff61d 100644 (file)
@@ -893,6 +893,7 @@ static struct qcam *qcam_init(struct parport *port)
 
        if (v4l2_device_register(NULL, v4l2_dev) < 0) {
                v4l2_err(v4l2_dev, "Could not register v4l2_device\n");
+               kfree(qcam);
                return NULL;
        }
 
index b8d800e600568913e3271cbcb2f45dd12f8db2aa..cd8ff0473184ea06a14bf38f0b97bfc82db91917 100644 (file)
@@ -750,6 +750,7 @@ static struct qcam *qcam_init(struct parport *port)
 
        if (v4l2_device_register(NULL, v4l2_dev) < 0) {
                v4l2_err(v4l2_dev, "Could not register v4l2_device\n");
+               kfree(qcam);
                return NULL;
        }