kernel_optimize_test/drivers/hid
Julia Lawall a809dda036 HID: fix memory leak on error patch in debug code
Error handling code following a kzalloc 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>
Cc: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-08-08 02:26:10 +02:00
..
usbhid HID: use debugfs for report dumping descriptor 2009-06-12 15:20:55 +02:00
hid-a4tech.c HID: remove compat stuff 2009-03-30 15:12:54 +02:00
hid-apple.c HID: Fix the support for apple mini aluminium keyboard 2009-04-29 11:55:18 +02:00
hid-belkin.c HID: remove compat stuff 2009-03-30 15:12:54 +02:00
hid-cherry.c HID: remove compat stuff 2009-03-30 15:12:54 +02:00
hid-chicony.c HID: remove compat stuff 2009-03-30 15:12:54 +02:00
hid-core.c HID: fix memory leak on error path in debug code 2009-06-26 10:50:12 +02:00
hid-cypress.c HID: remove compat stuff 2009-03-30 15:12:54 +02:00
hid-debug.c HID: fix memory leak on error patch in debug code 2009-08-08 02:26:10 +02:00
hid-drff.c HID: remove compat stuff 2009-03-30 15:12:54 +02:00
hid-ezkey.c HID: remove compat stuff 2009-03-30 15:12:54 +02:00
hid-gaff.c HID: remove compat stuff 2009-03-30 15:12:54 +02:00
hid-gyration.c HID: remove compat stuff 2009-03-30 15:12:54 +02:00
hid-ids.h HID: add NOGET quirk for devices from CH Products 2009-05-11 17:09:21 +02:00
hid-input.c HID: use debugfs for report dumping descriptor 2009-06-12 15:20:55 +02:00
hid-kensington.c HID: remove compat stuff 2009-03-30 15:12:54 +02:00
hid-kye.c HID: remove compat stuff 2009-03-30 15:12:54 +02:00
hid-lg2ff.c HID: convert to dev_* prints 2008-10-14 23:51:01 +02:00
hid-lg.c HID: Add support for the G25 force feedback wheel in native mode 2009-04-17 11:39:39 +02:00
hid-lg.h HID: move logitech FF processing 2008-10-14 23:50:56 +02:00
hid-lgff.c HID: Autocentering support for Logitech MOMO Racing Wheel 2008-10-14 23:50:58 +02:00
hid-microsoft.c HID: remove compat stuff 2009-03-30 15:12:54 +02:00
hid-monterey.c HID: remove compat stuff 2009-03-30 15:12:54 +02:00
hid-ntrig.c HID: remove compat stuff 2009-03-30 15:12:54 +02:00
hid-petalynx.c HID: remove compat stuff 2009-03-30 15:12:54 +02:00
hid-pl.c HID: remove compat stuff 2009-03-30 15:12:54 +02:00
hid-samsung.c HID: remove compat stuff 2009-03-30 15:12:54 +02:00
hid-sony.c HID: remove compat stuff 2009-03-30 15:12:54 +02:00
hid-sunplus.c HID: remove compat stuff 2009-03-30 15:12:54 +02:00
hid-tmff.c HID: remove compat stuff 2009-03-30 15:12:54 +02:00
hid-topseed.c HID: remove compat stuff 2009-03-30 15:12:54 +02:00
hid-zpff.c HID: remove compat stuff 2009-03-30 15:12:54 +02:00
hidraw.c HID: hidraw -- fix missing unlocks in unlocked_ioctl 2009-04-07 16:35:56 +02:00
Kconfig HID: use debugfs for report dumping descriptor 2009-06-12 15:20:55 +02:00
Makefile HID: use debugfs for report dumping descriptor 2009-06-12 15:20:55 +02:00