]> bbs.cooldavid.org Git - net-next-2.6.git/commit
[SCSI] lpfc: introduce missing kfree
authorJulia Lawall <julia@diku.dk>
Sun, 8 Feb 2009 21:43:19 +0000 (22:43 +0100)
committerJames Bottomley <James.Bottomley@HansenPartnership.com>
Tue, 10 Feb 2009 16:15:19 +0000 (11:15 -0500)
commite916141c6889e2a35869d7057ef1cc5e5a2e86eb
tree594ed76b74ae67796cbb6d7d43336a98e9ee3fb3
parent308cec14e6710b4d5b70e9778ce117be8371735d
[SCSI] lpfc: introduce missing kfree

Error handling code following a kmalloc should free the allocated data.

The semantic match that finds the problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@r exists@
local idexpression x;
statement S;
expression E;
identifier f,l;
position p1,p2;
expression *ptr != NULL;
@@

(
if ((x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...)) == NULL) S
|
x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...);
...
if (x == NULL) S
)
<... when != x
     when != if (...) { <+...x...+> }
x->f = E
...>
(
 return \(0\|<+...x...+>\|ptr\);
|
 return@p2 ...;
)

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

print "* file: %s kmalloc %s return %s" % (p1[0].file,p1[0].line,p2[0].line)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Acked-by: James Smart <james.smart@emulex.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
drivers/scsi/lpfc/lpfc_els.c