[PATCH 1/3] pcie: Don't search capabilities on removed devices

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

 



This patch returns immediately if trying to find a pcie capability
on a removed device, as seen with an all 1's completion from config
read. Previously this function would iterate the maximum 480 times to
search for a capability at position 0xffc. There is never a case where
we'd expect all 1's to a successful config read on a capability register,
so this is a safe criteria to check before bailing on the device.

While accessing a removed device shouldn't be fatal, it's doesn't
accomplish anything. Instead, the code was testing completion synthesis
capabilities which is observed to cause distruption to normal operations.

Signed-off-by: Keith Busch <keith.busch@xxxxxxxxx>
---
 drivers/pci/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index aab9d51..e884608 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -331,7 +331,7 @@ int pci_find_next_ext_capability(struct pci_dev *dev, int start, int cap)
 	if (header == 0)
 		return 0;
 
-	while (ttl-- > 0) {
+	while (ttl-- > 0 && header != -1) {
 		if (PCI_EXT_CAP_ID(header) == cap && pos != start)
 			return pos;
 
-- 
2.7.2

--
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