diff mbox

[3/5,v2] PCI: Add locking to pci_find_upstream_pcie_bridge()

Message ID 20101202153411.29125.10231.sendpatchset@localhost6.localdomain6 (mailing list archive)
State New, archived
Headers show

Commit Message

Stefan Assmann Dec. 2, 2010, 3:33 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index 9d75dc8..c8159b0 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -29,6 +29,8 @@  pci_find_upstream_pcie_bridge(struct pci_dev *pdev)
 
 	if (pci_is_pcie(pdev))
 		return NULL;
+
+	down_read(&pci_bus_sem);
 	while (1) {
 		if (pci_is_root_bus(pdev->bus))
 			break;
@@ -38,6 +40,7 @@  pci_find_upstream_pcie_bridge(struct pci_dev *pdev)
 			tmp = pdev;
 			continue;
 		}
+		up_read(&pci_bus_sem);
 		/* PCI device should connect to a PCIe bridge */
 		if (pdev->pcie_type != PCI_EXP_TYPE_PCI_BRIDGE) {
 			/* Busted hardware? */
@@ -46,6 +49,7 @@  pci_find_upstream_pcie_bridge(struct pci_dev *pdev)
 		}
 		return pdev;
 	}
+	up_read(&pci_bus_sem);
 
 	return tmp;
 }