diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2011-03-20 19:57:57 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2011-03-20 19:57:57 -0400 |
commit | 90407c9976939e061f32b0e07602e5ce4887d9e8 (patch) | |
tree | 9e962cdc2f11687751c8d37d74dad1abcd88e5e9 /arch | |
parent | a952baa034ae7c2e4a66932005cbc7ebbccfe28d (diff) |
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>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/kernel/pci_dn.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/arch/powerpc/kernel/pci_dn.c b/arch/powerpc/kernel/pci_dn.c index 29852688ceaa..d225d99fe39d 100644 --- a/arch/powerpc/kernel/pci_dn.c +++ b/arch/powerpc/kernel/pci_dn.c | |||
@@ -176,11 +176,14 @@ static void *is_devfn_node(struct device_node *dn, void *data) | |||
176 | */ | 176 | */ |
177 | struct device_node *fetch_dev_dn(struct pci_dev *dev) | 177 | struct device_node *fetch_dev_dn(struct pci_dev *dev) |
178 | { | 178 | { |
179 | struct device_node *orig_dn = dev->dev.of_node; | 179 | struct pci_controller *phb = dev->sysdata; |
180 | struct device_node *dn; | 180 | struct device_node *dn; |
181 | unsigned long searchval = (dev->bus->number << 8) | dev->devfn; | 181 | unsigned long searchval = (dev->bus->number << 8) | dev->devfn; |
182 | 182 | ||
183 | dn = traverse_pci_devices(orig_dn, is_devfn_node, (void *)searchval); | 183 | if (WARN_ON(!phb)) |
184 | return NULL; | ||
185 | |||
186 | dn = traverse_pci_devices(phb->dn, is_devfn_node, (void *)searchval); | ||
184 | if (dn) | 187 | if (dn) |
185 | dev->dev.of_node = dn; | 188 | dev->dev.of_node = dn; |
186 | return dn; | 189 | return dn; |