[PATCH] PCI/ASPM: Fix a NULL pointer crash on sparc64

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit d0751b98dfa3 ("PCI: Add dev->has_secondary_link to
track downstream PCIe links")assumed root port is always
the top device in pcie tree. But on sparc64 V245 and T2000
the pcie tree has no root port device in top level, the
upstream port device is connected directly to root bus.
So we may get NULL parent for this upstream port device.

Upstream port ------ Downstream port ------PCIe-PCI bridge

Reported-by: Meelis Roos <mroos@xxxxxxxx>
Tested-by: Meelis Roos <mroos@xxxxxxxx>
Signed-off-by: Yijing Wang <wangyijing@xxxxxxxxxx>
---
 drivers/pci/probe.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 51ebb97..cd54298 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1003,7 +1003,10 @@ void set_pcie_port_type(struct pci_dev *pdev)
 	else if (type == PCI_EXP_TYPE_UPSTREAM ||
 		 type == PCI_EXP_TYPE_DOWNSTREAM) {
 		parent = pci_upstream_bridge(pdev);
-		if (!parent->has_secondary_link)
+		/* For sparc64 V245 and T2000, upstream port may be
+		 * the top level device, connect to root bus directly.
+		 */
+		if (parent && !parent->has_secondary_link)
 			pdev->has_secondary_link = 1;
 	}
 }
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux