Skip to contentSkip to conversation

2.6 PCI Hotplug null pointer deref

PATCH Applied [email protected] 2 participants 2 messages Jul 1, 2004 – Jul 2, 2004

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.6 PCI Hotplug null pointer deref

Greg,

Please review the attached patch and, if acceptable, apply to the akpm/otrvalds/bkbits kernel tree.

This patch fixes a null-pointer dereference when hot-plug operations are performed on a machine that has virtual-io devices in it. Virtual i/o devices to not have pci bridges associated with them. It also corrects an ordering problem during hotplug remove.

This patch was previously reviewed/tested by Linda Xie, the current rpaphp maintainer.

--linas

===== drivers/pci/hotplug/rpaphp_pci.c 1.8 vs edited =====

drivers/pci/hotplug/rpaphp_pci.c +12 -3
@@ -378,8 +378,8 @@
 	
 		func = list_entry(ln, struct rpaphp_pci_func, sibling);
 		if (func->pci_dev) {
-			rpaphp_eeh_remove_bus_device(func->pci_dev);
 			pci_remove_bus_device(func->pci_dev); 
+			rpaphp_eeh_remove_bus_device(func->pci_dev);
 		}
 		kfree(func);
 	}
@@ -513,9 +513,18 @@
 		struct list_head *ln;
 
 		slot = list_entry(tmp, struct slot, rpaphp_slot_list);
+		if (slot->bridge == NULL) {
+			if (slot->dev_type == PCI_DEV) {
+				printk(KERN_WARNING "PCI slot missing bridge %s %s \n", 
+				                    slot->name, slot->location);
+			}
+			continue;
+		}
+
 		bus = slot->bridge->subordinate;
-		if (!bus)
-			return NULL; /* shouldn't be here */
+		if (!bus) {
+			continue;  /* should never happen? */
+		}
 		for (ln = bus->devices.next; ln != &bus->devices; ln = ln->next) {
                                 struct pci_dev *pdev = pci_dev_b(ln);
 				if (pdev == dev)
Applied
#1 lore raw
Quoted 11 lines · On Thu, Jul 01, 2004 at 06:16:05PM -0500, [email protected] wrote:

Greg,

Please review the attached patch and, if acceptable, apply to the akpm/otrvalds/bkbits kernel tree.

This patch fixes a null-pointer dereference when hot-plug operations are performed on a machine that has virtual-io devices in it. Virtual i/o devices to not have pci bridges associated with them. It also corrects an ordering problem during hotplug remove.

Quoted 6 lines

This patch was previously reviewed/tested by Linda Xie, the current rpaphp maintainer.

--linas

Applied, thanks.

greg k-h