UefiCpuPkg/PiSmmCpuDxeSmm: Add check to avoid NULL ptr dereference

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
This commit is contained in:
Hao Wu 2016-12-20 09:13:23 +08:00
parent 4fa9134e47
commit 403f54768c
1 changed files with 8 additions and 0 deletions

View File

@ -1011,6 +1011,10 @@ GetUefiMemoryMap (
} }
} while (Status == EFI_BUFFER_TOO_SMALL); } while (Status == EFI_BUFFER_TOO_SMALL);
if (MemoryMap == NULL) {
return ;
}
SortMemoryMap (MemoryMap, UefiMemoryMapSize, mUefiDescriptorSize); SortMemoryMap (MemoryMap, UefiMemoryMapSize, mUefiDescriptorSize);
MergeMemoryMapForNotPresentEntry (MemoryMap, &UefiMemoryMapSize, mUefiDescriptorSize); MergeMemoryMapForNotPresentEntry (MemoryMap, &UefiMemoryMapSize, mUefiDescriptorSize);
@ -1080,6 +1084,10 @@ IsSmmCommBufferForbiddenAddress (
UINTN MemoryMapEntryCount; UINTN MemoryMapEntryCount;
UINTN Index; UINTN Index;
if (mUefiMemoryMap == NULL) {
return FALSE;
}
MemoryMap = mUefiMemoryMap; MemoryMap = mUefiMemoryMap;
MemoryMapEntryCount = mUefiMemoryMapSize/mUefiDescriptorSize; MemoryMapEntryCount = mUefiMemoryMapSize/mUefiDescriptorSize;
for (Index = 0; Index < MemoryMapEntryCount; Index++) { for (Index = 0; Index < MemoryMapEntryCount; Index++) {