From b77e3aba66c5b1663108b0fa3383764dafd7a989 Mon Sep 17 00:00:00 2001 From: LeoLiu-oc Date: Mon, 20 Oct 2025 16:03:37 +0800 Subject: [PATCH] PCI: Fix PCIe unplug Enumeration Long Blocking Issue zhaoxin inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/ID2OAK 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. Reviewed-by: Weitao Wang Tested-by: Lyle Li 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 6743cce7532d..e8c18e99101f 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -591,6 +591,9 @@ u16 pci_find_next_ext_capability(struct pci_dev *dev, u16 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