From 2b8a606ca38a139cc1744db7212ea9b238881724 Mon Sep 17 00:00:00 2001 From: leoliu-oc Date: Thu, 30 Oct 2025 16:08:34 +0800 Subject: [PATCH] PCI: Fix PCIe unplug Enumeration Long Blocking Issue zhaoxin inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/IDAQNP CVE: NA ------------------- When a USB4 device is inserted, a PCIe tunnel will be established. Then, the PCIe hierarchy within the USB4 device will be enumerated. If the device is suddenly unplugged during the enumeration process, it is possible that the function pci_find_next_ext_capability called when the PCI driver scans the PCIe extended capability may take a very long time, perhaps more than 20 seconds. Signed-off-by: leoliu-oc --- drivers/pci/pci.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index b93605616d4e4..12ddeb44db4ff 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -513,6 +513,9 @@ int pci_find_next_ext_capability(struct pci_dev *dev, int start, int cap) return 0; while (ttl-- > 0) { + if (header == 0xffffffff) + return 0; + if (PCI_EXT_CAP_ID(header) == cap && pos != start) return pos; -- Gitee