From 264914a512f06916aae0e5c292d1f9676ddbbb3d Mon Sep 17 00:00:00 2001 From: Hao Wu Date: Mon, 30 Jul 2018 13:17:31 +0800 Subject: [PATCH] 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 --- MdePkg/Library/SmmMemLib/SmmMemLib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); -- 2.39.2