Skip to content

Commit

Permalink
[media] imon: Correct call to input_free_device
Browse files Browse the repository at this point in the history
ictx->touch is intialied in imon_init_intf1, to the result of calling the
function that contains this code.  Thus, in this code, input_free_device
should be called on touch itself.

A simplified version of the semantic match that finds this problem is:
(http://coccinelle.lip6.fr/)

// <smpl>
@r exists@
local idexpression struct input_dev * x;
expression ra,rr;
position p1,p2;
@@

x = input_allocate_device@p1(...)
...  when != x = rr
    when != input_free_device(x,...)
    when != if (...) { ... input_free_device(x,...) ...}
if(...) { ... when != x = ra
    when forall
    when != input_free_device(x,...)
\(return <+...x...+>; \| return@p2...; \) }

@script:python@
p1 << r.p1;
p2 << r.p2;
@@

cocci.print_main("input_allocate_device",p1)
cocci.print_secs("input_free_device",p2)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Julia Lawall authored and Mauro Carvalho Chehab committed May 20, 2011
1 parent da4b7b2 commit aeb35eb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/media/rc/imon.c
Original file line number Diff line number Diff line change
Expand Up @@ -1970,7 +1970,7 @@ static struct input_dev *imon_init_touch(struct imon_context *ictx)
return touch;

touch_register_failed:
input_free_device(ictx->touch);
input_free_device(touch);

touch_alloc_failed:
return NULL;
Expand Down

0 comments on commit aeb35eb

Please sign in to comment.