Skip to contentSkip to conversation

PCIe: AER: during disable, check subordinate before walking

PATCH In review Alex Chiang 2 participants 2 messages Mar 6, 2009 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCIe: AER: during disable, check subordinate before walking

Commit 47a8b0cc (Enable PCIe AER only after checking firmware support) wants to walk the PCI bus in the remove path to disable AER, and calls pci_walk_bus for downstream bridges.

Unfortunately, in the remove path, we remove devices and bridges in a depth-first manner, starting with the furthest downstream bridge and working our way backwards.

The furthest downstream bridges will not have a dev->subordinate, and we hit a NULL deref in pci_walk_bus.

Check for dev->subordinate first before attempting to walk the PCI hierarchy below us.

Cc Andrew Patterson <[email protected]>

---
Willy, this is .29 material, please push to Linus, thanks.

---

drivers/pci/pcie/aer/aerdrv_core.c +3 -0
index aebb5f6..677d680 100644
@@ -133,6 +133,9 @@ static void set_downstream_devices_error_reporting(struct pci_dev *dev,
 						   bool enable)
 {
 	set_device_error_reporting(dev, &enable);
+
+	if (!dev->subordinate)
+		return;
 	pci_walk_bus(dev->subordinate, set_device_error_reporting, &enable);
 }
 
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Alex Chiang

Commit 47a8b0cc (Enable PCIe AER only after checking firmware support) wants to walk the PCI bus in the remove path to disable AER, and calls pci_walk_bus for downstream bridges.

Unfortunately, in the remove path, we remove devices and bridges in a depth-first manner, starting with the furthest downstream bridge and working our way backwards.

Quoted 6 lines

The furthest downstream bridges will not have a dev->subordinate, and we hit a NULL deref in pci_walk_bus.

Check for dev->subordinate first before attempting to walk the PCI hierarchy below us.

Looks good.

Quoted 20 lines
Cc Andrew Patterson <[email protected]>

---
Willy, this is .29 material, please push to Linus, thanks.

---

drivers/pci/pcie/aer/aerdrv_core.c +3 -0
index aebb5f6..677d680 100644
@@ -133,6 +133,9 @@ static void set_downstream_devices_error_reporting(struct pci_dev *dev,
 						   bool enable)
 {
 	set_device_error_reporting(dev, &enable);
+
+	if (!dev->subordinate)
+		return;
 	pci_walk_bus(dev->subordinate, set_device_error_reporting, &enable);
 }
 
Signature · 2 lines
Andrew Patterson
Hewlett-Packard Company