]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: acpiview: FADT: Validate global pointer before use
authorKrzysztof Koch <krzysztof.koch@arm.com>
Mon, 20 Jan 2020 11:13:43 +0000 (19:13 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 11 Feb 2020 02:12:45 +0000 (02:12 +0000)
Check if global pointers have been successfully updated before they
are used for further table parsing.

Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c

index 8acfbac3b1d4a0071cf2481a6852bf6c2d95e91a..d86718bab67d45fd612bb7ac725b5eb3eeb7dfdc 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   FADT table parser\r
 \r
-  Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.\r
+  Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
   @par Reference(s):\r
@@ -230,9 +230,11 @@ ParseAcpiFadt (
     );\r
 \r
   if (Trace) {\r
-    Print (L"\nSummary:\n");\r
-    PrintFieldName (2, L"FADT Version");\r
-    Print (L"%d.%d\n",  *AcpiHdrInfo.Revision, *FadtMinorRevision);\r
+    if (FadtMinorRevision != NULL) {\r
+      Print (L"\nSummary:\n");\r
+      PrintFieldName (2, L"FADT Version");\r
+      Print (L"%d.%d\n",  *AcpiHdrInfo.Revision, *FadtMinorRevision);\r
+    }\r
 \r
     if (*GetAcpiXsdtHeaderInfo ()->OemTableId != *AcpiHdrInfo.OemTableId) {\r
       IncrementErrorCount ();\r
@@ -294,21 +296,20 @@ ParseAcpiFadt (
       );\r
   }\r
 \r
-  // If X_DSDT is not zero then use X_DSDT and ignore DSDT,\r
-  // else use DSDT.\r
-  if (*X_DsdtAddress != 0) {\r
+  // If X_DSDT is valid then use X_DSDT and ignore DSDT, else use DSDT.\r
+  if ((X_DsdtAddress != NULL) && (*X_DsdtAddress != 0)) {\r
     DsdtPtr = (UINT8*)(UINTN)(*X_DsdtAddress);\r
-  } else if (*DsdtAddress != 0) {\r
+  } else if ((DsdtAddress != NULL) && (*DsdtAddress != 0)) {\r
     DsdtPtr = (UINT8*)(UINTN)(*DsdtAddress);\r
   } else {\r
-    // Both DSDT and X_DSDT cannot be zero.\r
+    // Both DSDT and X_DSDT cannot be invalid.\r
 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)\r
     if (Trace) {\r
       // The DSDT Table is mandatory for ARM systems\r
       // as the CPU information MUST be presented in\r
       // the DSDT.\r
       IncrementErrorCount ();\r
-      Print (L"ERROR: Both X_DSDT and DSDT are NULL.\n");\r
+      Print (L"ERROR: Both X_DSDT and DSDT are invalid.\n");\r
     }\r
 #endif\r
     return;\r