From 4db69b4470b99b987e5f73ebb63098f382f1a2ab Mon Sep 17 00:00:00 2001 From: Hao Wu Date: Mon, 30 Jul 2018 13:17:31 +0800 Subject: 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 (cherry picked from commit 264914a512f06916aae0e5c292d1f9676ddbbb3d) --- MdePkg/Library/SmmMemLib/SmmMemLib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MdePkg/Library') diff --git a/MdePkg/Library/SmmMemLib/SmmMemLib.c b/MdePkg/Library/SmmMemLib/SmmMemLib.c index b401856af4..8c987b9e30 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); -- cgit v1.2.3