drivers/char/agp/parisc-agp.c: eliminate memory leak
authorJulia Lawall <[email protected]>
Wed, 20 Oct 2010 22:55:45 +0000 (15:55 -0700)
committerKyle McMartin <[email protected]>
Fri, 22 Oct 2010 01:03:47 +0000 (21:03 -0400)
commit338e4fab3d41aa14264e10ce505a7c908633cdad
tree66f754dfe6995eb9456c685143aa0ffc65b1735d
parent7da1272547ebe96982a42292dfc833457708f4da
drivers/char/agp/parisc-agp.c: eliminate memory leak

alloc_pci_dev allocates some memory, so that memory should be freed before
leaving the function in an error case.

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

// <smpl>
@r exists@
local idexpression x;
expression E;
identifier f1;
iterator I;
@@

x = alloc_pci_dev(...);
<... when != x
     when != true (x == NULL || ...)
     when != if (...) { <+...x...+> }
     when != I (...) { <+...x...+> }
(
 x == NULL
|
 x == E
|
 x->f1
)
...>
* return ...;
// </smpl>

Signed-off-by: Julia Lawall <[email protected]>
Dan Carpenter <[email protected]>
Dave Airlie <[email protected]>
Cc: Helge Deller <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Kyle McMartin <[email protected]>
drivers/char/agp/parisc-agp.c