From: Hao Wu Date: Mon, 30 Jul 2018 05:17:31 +0000 (+0800) Subject: MdePkg/SmmMemLib: Avoid possible NULL ptr dereference X-Git-Tag: edk2-stable201903~1316 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=264914a512f06916aae0e5c292d1f9676ddbbb3d;p=mirror_edk2.git MdePkg/SmmMemLib: Avoid possible NULL ptr dereference Within function SmmMemLibInternalGetUefiMemoryAttributesTable(), add a check to avoid possible null pointer dereference. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu Reviewed-by: Jiewen Yao --- diff --git a/MdePkg/Library/SmmMemLib/SmmMemLib.c b/MdePkg/Library/SmmMemLib/SmmMemLib.c index 3409ddf87c..3987af1eba 100644 --- a/MdePkg/Library/SmmMemLib/SmmMemLib.c +++ b/MdePkg/Library/SmmMemLib/SmmMemLib.c @@ -439,7 +439,7 @@ SmmMemLibInternalGetUefiMemoryAttributesTable ( UINTN MemoryAttributesTableSize; Status = EfiGetSystemConfigurationTable (&gEfiMemoryAttributesTableGuid, (VOID **)&MemoryAttributesTable); - if (!EFI_ERROR (Status)) { + if (!EFI_ERROR (Status) && (MemoryAttributesTable != NULL)) { MemoryAttributesTableSize = sizeof(EFI_MEMORY_ATTRIBUTES_TABLE) + MemoryAttributesTable->DescriptorSize * MemoryAttributesTable->NumberOfEntries; mSmmMemLibMemoryAttributesTable = AllocateCopyPool (MemoryAttributesTableSize, MemoryAttributesTable); ASSERT (mSmmMemLibMemoryAttributesTable != NULL);