MdePkg/SmmMemLib: Avoid possible NULL ptr dereference
authorHao Wu <hao.a.wu@intel.com>
Mon, 30 Jul 2018 05:17:31 +0000 (13:17 +0800)
committerHao Wu <hao.a.wu@intel.com>
Tue, 31 Jul 2018 05:07:44 +0000 (13:07 +0800)
Within function SmmMemLibInternalGetUefiMemoryAttributesTable(), add a
check to avoid possible null pointer dereference.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
MdePkg/Library/SmmMemLib/SmmMemLib.c

index 3409ddf..3987af1 100644 (file)
@@ -439,7 +439,7 @@ SmmMemLibInternalGetUefiMemoryAttributesTable (
   UINTN                        MemoryAttributesTableSize;\r
 \r
   Status = EfiGetSystemConfigurationTable (&gEfiMemoryAttributesTableGuid, (VOID **)&MemoryAttributesTable);\r
-  if (!EFI_ERROR (Status)) {\r
+  if (!EFI_ERROR (Status) && (MemoryAttributesTable != NULL)) {\r
     MemoryAttributesTableSize = sizeof(EFI_MEMORY_ATTRIBUTES_TABLE) + MemoryAttributesTable->DescriptorSize * MemoryAttributesTable->NumberOfEntries;\r
     mSmmMemLibMemoryAttributesTable = AllocateCopyPool (MemoryAttributesTableSize, MemoryAttributesTable);\r
     ASSERT (mSmmMemLibMemoryAttributesTable != NULL);\r