Julia Lawall
00b275dbfc
drivers/mtd/maps: 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,f1,l;
position p1,p2;
expression *ptr != NULL;
@@
x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...);
...
if (x == NULL) S
<... when != x
when != if (...) { <+...x...+> }
(
x->f1 = E
|
(x->f1 == NULL || ...)
|
f(...,x->f1,...)
)
...>
(
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>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2010-06-03 11:29:25 +01:00
..
2010-03-30 22:02:32 +09:00
2010-05-10 14:32:46 +01:00
2010-02-25 12:50:45 +00:00
2010-03-30 22:02:32 +09:00
2009-09-15 09:37:12 -07:00
2010-03-30 22:02:32 +09:00
2010-03-30 22:02:32 +09:00
2010-03-30 22:02:32 +09:00
2008-12-10 13:01:32 +00:00
2009-06-24 16:02:06 +01:00
2010-03-30 22:02:32 +09:00
2010-05-13 21:23:06 +01:00
2010-05-13 21:23:06 +01:00
2010-05-14 03:23:01 +01:00
2010-03-01 14:19:05 -08:00
2009-01-09 14:17:50 +00:00
2010-03-30 22:02:32 +09:00
2010-05-21 07:25:43 -07:00
2010-06-03 11:29:25 +01:00
2010-04-20 08:53:52 +01:00
2010-05-10 14:32:46 +01:00
2010-02-05 12:22:34 +01:00
2010-03-30 22:02:32 +09:00
2010-05-13 21:23:06 +01:00
2009-05-26 16:45:44 +01:00
2009-11-16 16:13:35 +00:00
2010-03-30 22:02:32 +09:00
2008-12-10 13:37:21 +00:00
2010-03-30 22:02:32 +09:00
2009-09-19 11:44:51 -07:00
2010-03-30 22:02:32 +09:00
2010-03-30 22:02:32 +09:00