]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmarAcpiTable.c
IntelSiliconPkg IntelVTdDxe: Fix potential NULL pointer dereference
[mirror_edk2.git] / IntelSiliconPkg / Feature / VTd / IntelVTdDxe / DmarAcpiTable.c
index b16bd93d53f135238bca446efc57557f224e50f8..342830a01fb05135706b610c8225fac98ab5eb78 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-  Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -27,7 +27,7 @@ typedef struct {
 \r
 #pragma pack()\r
 \r
-EFI_ACPI_DMAR_HEADER  *mAcpiDmarTable;\r
+EFI_ACPI_DMAR_HEADER  *mAcpiDmarTable = NULL;\r
 \r
 /**\r
   Dump DMAR DeviceScopeEntry.\r
@@ -889,7 +889,7 @@ ScanTableInRSDT (
   EntryPtr = &Rsdt->Entry;\r
   for (Index = 0; Index < EntryCount; Index ++, EntryPtr ++) {\r
     Table = (EFI_ACPI_DESCRIPTION_HEADER*)((UINTN)(*EntryPtr));\r
-    if (Table->Signature == Signature) {\r
+    if ((Table != NULL) && (Table->Signature == Signature)) {\r
       return Table;\r
     }\r
   }\r
@@ -923,7 +923,7 @@ ScanTableInXSDT (
   for (Index = 0; Index < EntryCount; Index ++) {\r
     CopyMem (&EntryPtr, (VOID *)(BasePtr + Index * sizeof(UINT64)), sizeof(UINT64));\r
     Table = (EFI_ACPI_DESCRIPTION_HEADER*)((UINTN)(EntryPtr));\r
-    if (Table->Signature == Signature) {\r
+    if ((Table != NULL) && (Table->Signature == Signature)) {\r
       return Table;\r
     }\r
   }\r