WSL2-Linux-Kernel/drivers/scsi/pm8001
Julia Lawall 823d219f23 [SCSI] pm8001: 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;
expression E;
identifier f,f1;
position p1,p2;
@@

x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...);
<... when != x
     when != if (...) { <+...x...+> }
     when != (x) == NULL
     when != (x) != NULL
     when != (x) == 0
     when != (x) != 0
(
x->f1 = E
|
 (x->f1 == NULL || ...)
|
 f(...,x->f1,...)
)
...>
(
 return <+...x...+>;
|
 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: jack wang <jack_wang@usish.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2010-08-06 12:06:08 -05:00
..
Makefile [SCSI] pm8001: add SAS/SATA HBA driver 2009-12-04 12:00:40 -06:00
pm8001_chips.h [SCSI] pm8001: add SAS/SATA HBA driver 2009-12-04 12:00:40 -06:00
pm8001_ctl.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
pm8001_ctl.h [SCSI] pm8001: enable read HBA SAS address from VPD 2009-12-10 10:09:23 -06:00
pm8001_defs.h [SCSI] pm8001: add SAS/SATA HBA driver 2009-12-04 12:00:40 -06:00
pm8001_hwi.c [SCSI] pm8001: introduce missing kfree 2010-08-06 12:06:08 -05:00
pm8001_hwi.h [SCSI] pm8001: fix endian issues with SAS address 2009-12-10 10:02:22 -06:00
pm8001_init.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
pm8001_sas.c [SCSI] Unify SAM_ and SAM_STAT_ macros 2010-07-28 09:07:49 -05:00
pm8001_sas.h [SCSI] pm8001: misc code cleanup 2009-12-10 10:10:56 -06:00