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
This commit is contained in:
Ruiyu Ni 2015-09-15 08:38:16 +00:00 committed by niruiyu
parent d20b06a3af
commit 7d9340a3f0
1 changed files with 8 additions and 0 deletions

View File

@ -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);
}