summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Bus
diff options
context:
space:
mode:
authorRuiyu Ni <ruiyu.ni@intel.com>2015-09-15 08:38:16 +0000
committerniruiyu <niruiyu@Edk2>2015-09-15 08:38:16 +0000
commit7d9340a3f082d2af4e69058e3083d08084d6c330 (patch)
treef89307797aa81b5f053846aad17984179cdcca13 /MdeModulePkg/Bus
parentd20b06a3afdf9335b6c71ff56e31003cbe1cd0c1 (diff)
downloadedk2-7d9340a3f082d2af4e69058e3083d08084d6c330.tar.gz
edk2-7d9340a3f082d2af4e69058e3083d08084d6c330.tar.bz2
edk2-7d9340a3f082d2af4e69058e3083d08084d6c330.zip
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 <ruiyu.ni@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18473 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Bus')
-rw-r--r--MdeModulePkg/Bus/Pci/PciBusDxe/PciCommand.c8
1 files changed, 8 insertions, 0 deletions
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);
}