From: Yinghai Lu Date: Thu, 30 Oct 2014 16:17:25 +0000 (-0600) Subject: PCI: Don't oops on virtual buses in acpi_pci_get_bridge_handle() X-Git-Tag: v3.18-rc4~16^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=32f638fc11db0526c706454d9ab4339d55ac89f3;p=profile%2Fcommon%2Fplatform%2Fkernel%2Flinux-artik7.git PCI: Don't oops on virtual buses in acpi_pci_get_bridge_handle() 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: 6cd33649fa83 ("PCI: Add pci_configure_device() during enumeration") Link: https://bugzilla.kernel.org/show_bug.cgi?id=87591 Reported-by: Chao Zhou Reported-by: Joerg Roedel Signed-off-by: Yinghai Lu Signed-off-by: Bjorn Helgaas --- diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h index 64dacb7..24c7728 100644 --- a/include/linux/pci-acpi.h +++ b/include/linux/pci-acpi.h @@ -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); }