Skip to content

Commit

Permalink
PCI: Don't oops on virtual buses in acpi_pci_get_bridge_handle()
Browse files Browse the repository at this point in the history
acpi_pci_get_bridge_handle() returns the ACPI handle for the bridge device
(either a host bridge or a PCI-to-PCI bridge) leading to a PCI bus.  But
SR-IOV virtual functions can be on a virtual bus with no bridge leading to
it.  Return a NULL acpi_handle in this case instead of trying to
dereference the NULL pointer to the bridge.

This fixes a NULL pointer dereference oops in pci_get_hp_params() when
adding SR-IOV VF devices on virtual buses.

[bhelgaas: changelog, add comment in code]
Fixes: 6cd3364 ("PCI: Add pci_configure_device() during enumeration")
Link: https://bugzilla.kernel.org/show_bug.cgi?id=87591
Reported-by: Chao Zhou <[email protected]>
Reported-by: Joerg Roedel <[email protected]>
Signed-off-by: Yinghai Lu <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
  • Loading branch information
Yinghai Lu authored and bjorn-helgaas committed Nov 5, 2014
1 parent d8e7d53 commit 32f638f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion include/linux/pci-acpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ static inline acpi_handle acpi_pci_get_bridge_handle(struct pci_bus *pbus)

if (pci_is_root_bus(pbus))
dev = pbus->bridge;
else
else {
/* If pbus is a virtual bus, there is no bridge to it */
if (!pbus->self)
return NULL;

dev = &pbus->self->dev;
}

return ACPI_HANDLE(dev);
}
Expand Down

0 comments on commit 32f638f

Please sign in to comment.