mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04:00
MdeModulePkg: DxeCore: Adding check for underflow before subtraction
During DXE core memory service initialization, the system would check available resource descriptor hobs against the memory top from PHIT hob. However, it is possible that a given resource descriptor hob will not be larger than the cover the memory top, causing the Length calculation to underflow. This change adds a check for potential underflow before performing the subtraction. Signed-off-by: Kun Qin <kun.qin@microsoft.com>
This commit is contained in:
parent
5be1bccd9c
commit
feeb137d43
1 changed files with 8 additions and 2 deletions
|
|
@ -2430,8 +2430,14 @@ CoreInitializeMemoryServices (
|
|||
//
|
||||
Attributes = PhitResourceHob->ResourceAttribute;
|
||||
BaseAddress = PageAlignAddress (PhitHob->EfiMemoryTop);
|
||||
Length = PageAlignLength (ResourceHobMemoryTop - BaseAddress);
|
||||
FindLargestFreeRegion (&BaseAddress, &Length, (EFI_HOB_MEMORY_ALLOCATION *)GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION));
|
||||
|
||||
if (BaseAddress > ResourceHobMemoryTop) {
|
||||
Length = 0;
|
||||
} else {
|
||||
Length = PageAlignLength (ResourceHobMemoryTop - BaseAddress);
|
||||
FindLargestFreeRegion (&BaseAddress, &Length, (EFI_HOB_MEMORY_ALLOCATION *)GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION));
|
||||
}
|
||||
|
||||
if (Length < MinimalMemorySizeNeeded) {
|
||||
//
|
||||
// If that range is not large enough to intialize the DXE Core, then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue