Reviewed-by: Zhichao Gao <[email protected]>

Thanks,
Zhichao

> -----Original Message-----
> From: Krzysztof Koch [mailto:[email protected]]
> Sent: Monday, August 19, 2019 4:25 PM
> To: [email protected]
> Cc: Carsey, Jaben <[email protected]>; Ni, Ray <[email protected]>;
> Gao, Zhichao <[email protected]>; [email protected];
> [email protected]; [email protected]
> Subject: [PATCH v2 03/11] ShellPkg: acpiview: FADT: Validate global pointer
> before use
> 
> Check if global pointers have been successfully updated before they are
> used for further table parsing.
> 
> Signed-off-by: Krzysztof Koch <[email protected]>
> ---
> 
> Changes can be seen at:
> https://github.com/KrzysztofKoch1/edk2/tree/612_add_pointer_validation_
> v2
> 
> Notes:
>     v1:
>     - Test against NULL pointers [Krzysztof]
> 
>     v2:
>     - Do not require FadtMinorRevision and X_DsdtAddress pointers to be
>       valid in order to process the remaining ACPI tables [Zhichao]
> 
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c
> | 19 ++++++++++---------
>  1 file changed, 10 insertions(+), 9 deletions(-)
> 
> diff --git
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.
> c
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.
> c
> index
> e40c9ef8ee4b3285faf8c6edf3cb6236ee367397..6859c4824c2866fd3eb9a789a8
> dfc950724b27ca 100644
> ---
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.
> c
> +++
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtPars
> +++ er.c
> @@ -204,9 +204,11 @@ ParseAcpiFadt (
>      );
> 
>    if (Trace) {
> -    Print (L"\nSummary:\n");
> -    PrintFieldName (2, L"FADT Version");
> -    Print (L"%d.%d\n",  *AcpiHdrInfo.Revision, *FadtMinorRevision);
> +    if (FadtMinorRevision != NULL) {
> +      Print (L"\nSummary:\n");
> +      PrintFieldName (2, L"FADT Version");
> +      Print (L"%d.%d\n",  *AcpiHdrInfo.Revision, *FadtMinorRevision);
> +    }
> 
>      if (*GetAcpiXsdtHeaderInfo ()->OemTableId != *AcpiHdrInfo.OemTableId)
> {
>        IncrementErrorCount ();
> @@ -214,21 +216,20 @@ ParseAcpiFadt (
>      }
>    }
> 
> -  // If X_DSDT is not zero then use X_DSDT and ignore DSDT,
> -  // else use DSDT.
> -  if (*X_DsdtAddress != 0) {
> +  // If X_DSDT is valid then use X_DSDT and ignore DSDT, else use DSDT.
> +  if ((X_DsdtAddress != NULL) && (*X_DsdtAddress != 0)) {
>      DsdtPtr = (UINT8*)(UINTN)(*X_DsdtAddress);
> -  } else if (*DsdtAddress != 0) {
> +  } else if ((DsdtAddress != NULL) && (*DsdtAddress != 0)) {
>      DsdtPtr = (UINT8*)(UINTN)(*DsdtAddress);
>    } else {
> -    // Both DSDT and X_DSDT cannot be zero.
> +    // Both DSDT and X_DSDT cannot be invalid.
>  #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
>      if (Trace) {
>        // The DSDT Table is mandatory for ARM systems
>        // as the CPU information MUST be presented in
>        // the DSDT.
>        IncrementErrorCount ();
> -      Print (L"ERROR: Both X_DSDT and DSDT are NULL.\n");
> +      Print (L"ERROR: Both X_DSDT and DSDT are invalid.\n");
>      }
>  #endif
>      return;
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#46131): https://edk2.groups.io/g/devel/message/46131
Mute This Topic: https://groups.io/mt/32941781/21656
Group Owner: [email protected]
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to