linux/drivers/pci
Julia Lawall 0b3e7388e3 PCI: introduce missing kfree
Error handling code following a kmalloc should free the allocated data.
Since the subsequent code that could provoke an error does not use the
allocated data, the allocation is just moved below it.

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>
Reviewed-by: Matthew Wilcox <willy@linux.intel.com>
Reviewed-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
2009-03-19 19:29:28 -07:00
..
hotplug PCI: introduce missing kfree 2009-03-19 19:29:28 -07:00
pcie PCI/PCIe portdrv: Fix allocation of interrupts 2009-03-19 19:29:25 -07:00
.gitignore
access.c PCI: add interface to set visible size of VPD 2009-01-07 11:13:18 -08:00
bus.c PCI: factor pci_bus_add_child() from pci_bus_add_devices() 2009-01-07 11:13:06 -08:00
dmar.c intel-iommu: fix endless "Unknown DMAR structure type" loop 2009-02-14 08:33:34 +00:00
hotplug-pci.c PCI: fix section mismatch warning in pci_scan_child_bus 2008-03-04 15:07:03 -08:00
hotplug.c Driver core: change add_uevent_var to use a struct 2007-10-12 14:51:01 -07:00
htirq.c genirq: remove sparse irq code 2008-10-16 16:53:15 +02:00
intel-iommu.c PCI: add missing KERN_* constants to printks 2009-03-19 19:29:27 -07:00
intr_remapping.c VT-d: handle Invalidation Queue Error to avoid system hang 2009-02-09 11:03:17 +00:00
intr_remapping.h VT-d: Changes to support KVM 2008-10-15 14:24:08 +02:00
iova.c VT-d: Changes to support KVM 2008-10-15 14:24:08 +02:00
irq.c PCI: struct device - replace bus_id with dev_name(), dev_set_name() 2009-01-07 11:12:23 -08:00
Kconfig PCI: pci-stub module to reserve pci device 2009-01-07 11:12:38 -08:00
Makefile PCI: pci-stub module to reserve pci device 2009-01-07 11:12:38 -08:00
msi.c PCI/MSI: Use #ifdefs instead of weak functions 2009-03-19 19:29:26 -07:00
msi.h
pci-acpi.c Merge branch 'linus' into release 2009-01-09 03:39:43 -05:00
pci-driver.c PCI PM: make the PM core more careful with drivers using the new PM framework 2009-02-04 17:22:35 -08:00
pci-stub.c PCI: pci-stub module to reserve pci device 2009-01-07 11:12:38 -08:00
pci-sysfs.c PCI: return error on failure to read PCI ROMs 2009-02-04 16:58:41 -08:00
pci.c PCI: __FUNCTION__ is gcc-specific, use __func__ 2009-03-19 19:29:20 -07:00
pci.h PCI: fix struct pci_platform_pm_ops kernel-doc 2009-02-13 12:02:47 -08:00
probe.c Merge branch 'cpus4096-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2009-01-10 06:12:18 -08:00
proc.c PCI: define PCI resource names in an 'enum' 2009-01-07 11:13:01 -08:00
quirks.c pci: Fix typo in message while disabling HT MSI mapping 2009-03-12 15:42:29 -04:00
remove.c PCI: check if a bus is added when removing it 2009-03-19 19:29:26 -07:00
rom.c PCI: fix rom.c kernel-doc warning 2009-02-13 12:01:56 -08:00
search.c PCI: Fix reference counting bug 2008-10-22 16:42:35 -07:00
setup-bus.c PCI: use dev_printk for PCI bus resource mssages 2009-01-07 11:13:19 -08:00
setup-irq.c PCI: use dev_printk when possible 2008-06-25 16:05:13 -07:00
setup-res.c PCI: add a new function to map BAR offsets 2009-01-07 11:13:04 -08:00
slot.c PCI: stop leaking 'slot_name' in pci_create_slot 2008-12-09 14:36:03 -08:00
syscall.c [CVE-2009-0029] System call wrappers part 26 2009-01-14 14:15:29 +01:00