Skip to content

Commit

Permalink
arch/powerpc/sysdev/ehv_pic.c: add missing kfree
Browse files Browse the repository at this point in the history
At this point, ehv_pic has been allocated but not stored anywhere, so it
should be freed before leaving the function.

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

// <smpl>
@exists@
local idexpression x;
statement S,S1;
expression E;
identifier fl;
expression *ptr != NULL;
@@

x = \(kmalloc\|kzalloc\|kcalloc\)(...);
...
if (x == NULL) S
<... when != x
     when != if (...) { <+...kfree(x)...+> }
     when any
     when != true x == NULL
x->fl
...>
(
if (x == NULL) S1
|
if (...) { ... when != x
               when forall
(
 return \(0\|<+...x...+>\|ptr\);
|
* return ...;
)
}
)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Acked-by: Timur Tabi <timur@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
  • Loading branch information
Julia Lawall authored and Kumar Gala committed Nov 24, 2011
1 parent 7145cf1 commit e3854b6
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions arch/powerpc/sysdev/ehv_pic.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ void __init ehv_pic_init(void)

if (!ehv_pic->irqhost) {
of_node_put(np);
kfree(ehv_pic);
return;
}

Expand Down

0 comments on commit e3854b6

Please sign in to comment.