]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/pci/pci.c
PCI: fix oops when try to find Root Port for a PCI device
[karo-tx-linux.git] / drivers / pci / pci.c
index af0cc3456dc1b48b1325c06c5edd2ca8cc22a640..587cd7623ed878f51beb42cd2ea26269ef36cb7e 100644 (file)
@@ -522,10 +522,11 @@ struct pci_dev *pci_find_pcie_root_port(struct pci_dev *dev)
                bridge = pci_upstream_bridge(bridge);
        }
 
-       if (pci_pcie_type(highest_pcie_bridge) != PCI_EXP_TYPE_ROOT_PORT)
-               return NULL;
+       if (highest_pcie_bridge &&
+           pci_pcie_type(highest_pcie_bridge) == PCI_EXP_TYPE_ROOT_PORT)
+               return highest_pcie_bridge;
 
-       return highest_pcie_bridge;
+       return NULL;
 }
 EXPORT_SYMBOL(pci_find_pcie_root_port);