linux/drivers/staging
Julia Lawall e281cf8966 Staging: batman-adv: introduce missing kfree
Error handling code following a kzalloc should free the allocated data.
Similarly for usb-alloc urb.

The semantic match that finds the first 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>
Cc: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-12-23 11:27:50 -08:00
..
altpciechdma
arlan
asus_oled
b3dfg
batman-adv Staging: batman-adv: introduce missing kfree 2009-12-23 11:27:50 -08:00
comedi Staging: comedi: jr3_pci: Don't ioremap too much space. Check result. 2009-12-23 11:27:46 -08:00
cx25821
dream
echo
et131x
frontier
go7007
hv
iio
line6
mimio
netwave
octeon
otus
p9auth
panel Staging: panel: Adjust range for PANEL_KEYPAD in Kconfig 2009-12-23 11:27:49 -08:00
phison
poch
pohmelfs pohmelfs needs I_LOCK 2009-12-22 12:27:33 -05:00
quatech_usb2
ramzswap Staging: ramzswap: remove ARM specific d-cache hack 2009-12-23 11:27:49 -08:00
rar
rt2860
rt2870
rt3070
rt3090
rtl8187se Staging: fix rtl8187se compilation errors with mac80211 2009-12-23 11:27:46 -08:00
rtl8192e Staging: rtl8192x: fix printk formats 2009-12-23 11:27:48 -08:00
rtl8192su staging: rtl8192su: add USB VID/PID for HWNUm-300 2009-12-23 11:27:47 -08:00
rtl8192u Staging: rtl8192x: fix printk formats 2009-12-23 11:27:48 -08:00
samsung-laptop
sep
serqt_usb2
slicoss
sm7xx Staging: sm7xx: add a new framebuffer driver 2009-12-23 11:27:44 -08:00
strip
udlfb
usbip
vme
vt6655
vt6656
wavelan
winbond
wlags49_h2
wlags49_h25
wlan-ng Staging: wlan-ng: fix Correct size given to memset 2009-12-23 11:27:48 -08:00
Kconfig Staging: dst: remove from the tree 2009-12-23 11:27:45 -08:00
Makefile Staging: dst: remove from the tree 2009-12-23 11:27:45 -08:00
staging.c