Преглед изворни кода

powerpc/pci: Fix crash in PCI code on ppc64 when matching device nodes

Commit b5d937de0367d26f65b9af1aef5f2c34c1939be0 has a bug which causes
basically a NULL dereference in the PCI code during boot on ppc64
machines.

fetch_dev_dn() is called when dev->dev.of_node is NULL, so using that
as the starting point for the search makes no sense. It should instead
start from the device node of the PHB.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Benjamin Herrenschmidt пре 14 година
родитељ
комит
90407c9976
1 измењених фајлова са 5 додато и 2 уклоњено
  1. 5 2
      arch/powerpc/kernel/pci_dn.c

+ 5 - 2
arch/powerpc/kernel/pci_dn.c

@@ -176,11 +176,14 @@ static void *is_devfn_node(struct device_node *dn, void *data)
  */
 struct device_node *fetch_dev_dn(struct pci_dev *dev)
 {
-	struct device_node *orig_dn = dev->dev.of_node;
+	struct pci_controller *phb = dev->sysdata;
 	struct device_node *dn;
 	unsigned long searchval = (dev->bus->number << 8) | dev->devfn;
 
-	dn = traverse_pci_devices(orig_dn, is_devfn_node, (void *)searchval);
+	if (WARN_ON(!phb))
+		return NULL;
+
+	dn = traverse_pci_devices(phb->dn, is_devfn_node, (void *)searchval);
 	if (dn)
 		dev->dev.of_node = dn;
 	return dn;