[PATCH] (1/3) Fix unbalanced dev_get/put calls in PPC64 EEH code
From: Paul Mackerras
Date: Fri Jul 09 2004 - 06:04:05 EST
From: Linas Vepstas <linas@xxxxxxxxxxxxxx>
This patch fixes some unbalanced usage of pci_dev_get()/pci_dev_put() calls
in the eeh code. The old code had too many calls to dev_put, which could
cause memory structs to be freed prematurely, possibly leading to bad
bad pointer derefs in certain cases.
Signed-off-by: Linas Vepstas <linas@xxxxxxxxx>
Signed-off-by: Paul Mackerras <paulus@xxxxxxxxx>
diff -urN linux-2.5/arch/ppc64/kernel/eeh.c test25/arch/ppc64/kernel/eeh.c
--- linux-2.5/arch/ppc64/kernel/eeh.c 2004-07-06 08:43:03.000000000 +1000
+++ test25/arch/ppc64/kernel/eeh.c 2004-07-08 16:56:46.244591376 +1000
@@ -214,7 +214,6 @@
if (!dn) {
printk(KERN_WARNING "PCI: no pci dn found for dev=%s %s\n",
pci_name(dev), pci_pretty_name(dev));
- pci_dev_put(dev);
return;
}
@@ -225,10 +224,12 @@
printk(KERN_INFO "PCI: skip building address cache for=%s %s\n",
pci_name(dev), pci_pretty_name(dev));
#endif
- pci_dev_put(dev);
return;
}
+ /* The cache holds a reference to the device... */
+ pci_dev_get(dev);
+
/* Walk resources on this device, poke them into the tree */
for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
unsigned long start = pci_resource_start(dev,i);
@@ -278,6 +279,8 @@
}
n = rb_next(n);
}
+
+ /* The cache no longer holds its reference to this device... */
pci_dev_put(dev);
}
@@ -317,7 +320,6 @@
while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
/* Ignore PCI bridges ( XXX why ??) */
if ((dev->class >> 16) == PCI_BASE_CLASS_BRIDGE) {
- pci_dev_put(dev);
continue;
}
pci_addr_cache_insert_device(dev);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/