Skip to content

Commit

Permalink
[media] drivers/media/video: add missing kfree
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Julia Lawall authored and Mauro Carvalho Chehab committed Jul 27, 2011
1 parent 37f9619 commit ee893e9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/media/video/bw-qcam.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions drivers/media/video/c-qcam.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit ee893e9

Please sign in to comment.