From a7757cf69f830bcfb7c6eed4786b303f23f53140 Mon Sep 17 00:00:00 2001 From: Ruiyu Ni Date: Tue, 15 Sep 2015 08:47:05 +0000 Subject: 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. (Sync patch r18473 from main trunk.) 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/branches/UDK2015@18475 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Bus/Pci/PciBusDxe/PciCommand.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'MdeModulePkg/Bus') 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); } -- cgit v1.2.3