From: Ruiyu Ni Date: Tue, 15 Sep 2015 08:38:16 +0000 (+0000) Subject: MdeModulePkg: Enhance PCI capability looking up logic to avoid hang X-Git-Tag: edk2-stable201903~8860 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=7d9340a3f082d2af4e69058e3083d08084d6c330;p=mirror_edk2.git MdeModulePkg: Enhance PCI capability looking up logic to avoid hang Certain PCI device may have capability pointing to itself. Update LocateCapabilityRegBlock() to break when detecting such loop. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni Reviewed-by: Feng Tian git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18473 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciCommand.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciCommand.c index 8a8b4b8fac..0bc1fbfeff 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciCommand.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciCommand.c @@ -173,6 +173,14 @@ LocateCapabilityRegBlock ( return EFI_SUCCESS; } + // + // Certain PCI device may incorrectly have capability pointing to itself, + // break to avoid dead loop. + // + if (CapabilityPtr == (UINT8) (CapabilityEntry >> 8)) { + break; + } + CapabilityPtr = (UINT8) (CapabilityEntry >> 8); }