Re: [edk2-devel] [edk2-platforms][PATCH V1 1/1] MinPlatformPkg/MultiBoardInitSupportLib: Fix NULL pointer dereferences

2019-08-26 Thread Chiu, Chasel


Reviewed-by: Chasel Chiu 


> -Original Message-
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> Kubacki, Michael A
> Sent: Saturday, August 24, 2019 7:24 AM
> To: devel@edk2.groups.io
> Cc: Chiu, Chasel ; Desimone, Nathaniel L
> ; Gao, Liming 
> Subject: [edk2-devel] [edk2-platforms][PATCH V1 1/1]
> MinPlatformPkg/MultiBoardInitSupportLib: Fix NULL pointer dereferences
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2114
> 
> Removes potential NULL pointer de-references in the library and validates
> NULL pointers are not passed to library functions.
> 
> Cc: Chasel Chiu 
> Cc: Nate DeSimone 
> Cc: Liming Gao 
> Signed-off-by: Michael Kubacki 
> ---
>  Platform/Intel/MinPlatformPkg/Include/Library/MultiBoardInitSupportLib.h
> | 84 -
> 
> Platform/Intel/MinPlatformPkg/PlatformInit/Library/MultiBoardInitSupportL
> ib/DxeMultiBoardInitSupportLib.c | 24 -
> Platform/Intel/MinPlatformPkg/PlatformInit/Library/MultiBoardInitSupportL
> ib/PeiMultiBoardInitSupportLib.c | 97 +---
>  3 files changed, 188 insertions(+), 17 deletions(-)
> 
> diff --git
> a/Platform/Intel/MinPlatformPkg/Include/Library/MultiBoardInitSupportLib.
> h
> b/Platform/Intel/MinPlatformPkg/Include/Library/MultiBoardInitSupportLib.
> h
> index 6c14b5677d..a854f61e27 100644
> ---
> a/Platform/Intel/MinPlatformPkg/Include/Library/MultiBoardInitSupportLib.
> h
> +++ b/Platform/Intel/MinPlatformPkg/Include/Library/MultiBoardInitSuppor
> +++ tLib.h
> @@ -1,6 +1,6 @@
>  /** @file
> 
> -Copyright (c) 2017, Intel Corporation. All rights reserved.
> +Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
>  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
>  **/
> @@ -10,18 +10,39 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> 
>  #include 
> 
> +/**
> +  This board service detects the board type.
> +
> +  @retval EFI_SUCCESS   The board was detected successfully.
> +  @retval EFI_NOT_FOUND The board could not be detected.
> +
> +**/
>  typedef
>  EFI_STATUS
>  (EFIAPI *BOARD_DETECT) (
>VOID
>);
> 
> +/**
> +  This board service performs board-specific initialization.
> +
> +  @retval EFI_SUCCESS   Board-specific initialization was successful.
> +  @retval EFI_NOT_READY The board has not been detected yet.
> +
> +**/
>  typedef
>  EFI_STATUS
>  (EFIAPI *BOARD_INIT) (
>VOID
>);
> 
> +/**
> +  This board service detects the boot mode.
> +
> +  @retval EFI_BOOT_MODE The boot mode.
> +  @retval EFI_NOT_READY The board has not been detected yet.
> +
> +**/
>  typedef
>  EFI_BOOT_MODE
>  (EFIAPI *BOARD_BOOT_MODE_DETECT) (
> @@ -52,24 +73,85 @@ typedef struct {
>BOARD_INIT  BoardInitEndOfFirmware;
>  } BOARD_NOTIFICATION_INIT_FUNC;
> 
> +/**
> +  Registers the given function for callback during board detection.
> +
> +  When this function is called the given function pointer is added to
> + an internal list. When board detection is  performed within the
> + BoardDetect() API, the function pointers in the list will be invoked until a
> board  detection function reports it has successfully detected the board.
> +
> +  @param[in]BoardDetect A pointer to a function of type
> BOARD_DETECT_FUNC that is called during
> +board detection.
> +
> +  @retval   EFI_SUCCESS The function was successfully
> registered.
> +  @retval   EFI_INVALID_PARAMETER   The function pointer given is NULL.
> +  @retval   EFI_OUT_OF_RESOURCESInsufficient memory resources
> exist to add a new board detection callback.
> +
> +**/
>  EFI_STATUS
>  EFIAPI
>  RegisterBoardDetect (
>IN BOARD_DETECT_FUNC  *BoardDetect
>);
> 
> +/**
> +  Registers the given set of board functions for callback to perform
> pre-memory board initialization tasks.
> +
> +  When this function is called, the given structure of function
> + pointers are stored for future invocation. When  board pre-memory
> + initialization tasks are required, the corresponding pre-memory
> + function in this structure  will be called. Typically, 
> RegisterBoardPreMemInit()
> is called during board detection with the successfully  detected board
> providing its set of board-specific pre-memory initialization functions.
> +
> +  @param[in]BoardPreMemInit A pointer to a structure of function
> pointers described in the type
> +BOARD_PRE_MEM_INIT_FUNC.
> +
> +  @retval   EFI_SUCCESS The board pre-memory functions were
> successfully registered.
> 

Re: [edk2-devel] [edk2-platforms][PATCH V1 1/1] MinPlatformPkg/MultiBoardInitSupportLib: Fix NULL pointer dereferences

2019-08-23 Thread Nate DeSimone
Reviewed-by: Nate DeSimone 

-Original Message-
From: Kubacki, Michael A 
Sent: Friday, August 23, 2019 4:24 PM
To: devel@edk2.groups.io
Cc: Chiu, Chasel ; Desimone, Nathaniel L 
; Gao, Liming 
Subject: [edk2-platforms][PATCH V1 1/1] 
MinPlatformPkg/MultiBoardInitSupportLib: Fix NULL pointer dereferences

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2114

Removes potential NULL pointer de-references in the library and validates NULL 
pointers are not passed to library functions.

Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Liming Gao 
Signed-off-by: Michael Kubacki 
---
 Platform/Intel/MinPlatformPkg/Include/Library/MultiBoardInitSupportLib.h   
   | 84 -
 
Platform/Intel/MinPlatformPkg/PlatformInit/Library/MultiBoardInitSupportLib/DxeMultiBoardInitSupportLib.c
 | 24 -  
Platform/Intel/MinPlatformPkg/PlatformInit/Library/MultiBoardInitSupportLib/PeiMultiBoardInitSupportLib.c
 | 97 +---
 3 files changed, 188 insertions(+), 17 deletions(-)

diff --git 
a/Platform/Intel/MinPlatformPkg/Include/Library/MultiBoardInitSupportLib.h 
b/Platform/Intel/MinPlatformPkg/Include/Library/MultiBoardInitSupportLib.h
index 6c14b5677d..a854f61e27 100644
--- a/Platform/Intel/MinPlatformPkg/Include/Library/MultiBoardInitSupportLib.h
+++ b/Platform/Intel/MinPlatformPkg/Include/Library/MultiBoardInitSuppor
+++ tLib.h
@@ -1,6 +1,6 @@
 /** @file
 
-Copyright (c) 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -10,18 +10,39 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 
 #include 
 
+/**
+  This board service detects the board type.
+
+  @retval EFI_SUCCESS   The board was detected successfully.
+  @retval EFI_NOT_FOUND The board could not be detected.
+
+**/
 typedef
 EFI_STATUS
 (EFIAPI *BOARD_DETECT) (
   VOID
   );
 
+/**
+  This board service performs board-specific initialization.
+
+  @retval EFI_SUCCESS   Board-specific initialization was successful.
+  @retval EFI_NOT_READY The board has not been detected yet.
+
+**/
 typedef
 EFI_STATUS
 (EFIAPI *BOARD_INIT) (
   VOID
   );
 
+/**
+  This board service detects the boot mode.
+
+  @retval EFI_BOOT_MODE The boot mode.
+  @retval EFI_NOT_READY The board has not been detected yet.
+
+**/
 typedef
 EFI_BOOT_MODE
 (EFIAPI *BOARD_BOOT_MODE_DETECT) (
@@ -52,24 +73,85 @@ typedef struct {
   BOARD_INIT  BoardInitEndOfFirmware;
 } BOARD_NOTIFICATION_INIT_FUNC;
 
+/**
+  Registers the given function for callback during board detection.
+
+  When this function is called the given function pointer is added to 
+ an internal list. When board detection is  performed within the 
+ BoardDetect() API, the function pointers in the list will be invoked until a 
board  detection function reports it has successfully detected the board.
+
+  @param[in]BoardDetect A pointer to a function of type 
BOARD_DETECT_FUNC that is called during
+board detection.
+
+  @retval   EFI_SUCCESS The function was successfully 
registered.
+  @retval   EFI_INVALID_PARAMETER   The function pointer given is NULL.
+  @retval   EFI_OUT_OF_RESOURCESInsufficient memory resources exist to 
add a new board detection callback.
+
+**/
 EFI_STATUS
 EFIAPI
 RegisterBoardDetect (
   IN BOARD_DETECT_FUNC  *BoardDetect
   );
 
+/**
+  Registers the given set of board functions for callback to perform 
pre-memory board initialization tasks.
+
+  When this function is called, the given structure of function 
+ pointers are stored for future invocation. When  board pre-memory 
+ initialization tasks are required, the corresponding pre-memory 
+ function in this structure  will be called. Typically, 
RegisterBoardPreMemInit() is called during board detection with the 
successfully  detected board providing its set of board-specific pre-memory 
initialization functions.
+
+  @param[in]BoardPreMemInit A pointer to a structure of function 
pointers described in the type
+BOARD_PRE_MEM_INIT_FUNC.
+
+  @retval   EFI_SUCCESS The board pre-memory functions were 
successfully registered.
+  @retval   EFI_INVALID_PARAMETER   The pointer given is NULL.
+  @retval   EFI_OUT_OF_RESOURCESInsufficient memory resources exist to 
register the callback functions.
+
+**/
 EFI_STATUS
 EFIAPI
 RegisterBoardPreMemInit (
   IN BOARD_PRE_MEM_INIT_FUNC  *BoardPreMemInit
   );
 
+/**
+  Registers the given set of board functions for callback to perform 
post-memory board initialization tasks.
+
+  When this function is called, the given structure of function 
+ pointers are stored for future invocation. When  board post-memory 
+ initialization tasks are required, the corresponding post-memory 
+ function in this structure  will be called. Typically, 
RegisterBoardPostMemInit() is called 

[edk2-devel] [edk2-platforms][PATCH V1 1/1] MinPlatformPkg/MultiBoardInitSupportLib: Fix NULL pointer dereferences

2019-08-23 Thread Kubacki, Michael A
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2114

Removes potential NULL pointer de-references in the library and
validates NULL pointers are not passed to library functions.

Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Liming Gao 
Signed-off-by: Michael Kubacki 
---
 Platform/Intel/MinPlatformPkg/Include/Library/MultiBoardInitSupportLib.h   
   | 84 -
 
Platform/Intel/MinPlatformPkg/PlatformInit/Library/MultiBoardInitSupportLib/DxeMultiBoardInitSupportLib.c
 | 24 -
 
Platform/Intel/MinPlatformPkg/PlatformInit/Library/MultiBoardInitSupportLib/PeiMultiBoardInitSupportLib.c
 | 97 +---
 3 files changed, 188 insertions(+), 17 deletions(-)

diff --git 
a/Platform/Intel/MinPlatformPkg/Include/Library/MultiBoardInitSupportLib.h 
b/Platform/Intel/MinPlatformPkg/Include/Library/MultiBoardInitSupportLib.h
index 6c14b5677d..a854f61e27 100644
--- a/Platform/Intel/MinPlatformPkg/Include/Library/MultiBoardInitSupportLib.h
+++ b/Platform/Intel/MinPlatformPkg/Include/Library/MultiBoardInitSupportLib.h
@@ -1,6 +1,6 @@
 /** @file
 
-Copyright (c) 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -10,18 +10,39 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 
 #include 
 
+/**
+  This board service detects the board type.
+
+  @retval EFI_SUCCESS   The board was detected successfully.
+  @retval EFI_NOT_FOUND The board could not be detected.
+
+**/
 typedef
 EFI_STATUS
 (EFIAPI *BOARD_DETECT) (
   VOID
   );
 
+/**
+  This board service performs board-specific initialization.
+
+  @retval EFI_SUCCESS   Board-specific initialization was successful.
+  @retval EFI_NOT_READY The board has not been detected yet.
+
+**/
 typedef
 EFI_STATUS
 (EFIAPI *BOARD_INIT) (
   VOID
   );
 
+/**
+  This board service detects the boot mode.
+
+  @retval EFI_BOOT_MODE The boot mode.
+  @retval EFI_NOT_READY The board has not been detected yet.
+
+**/
 typedef
 EFI_BOOT_MODE
 (EFIAPI *BOARD_BOOT_MODE_DETECT) (
@@ -52,24 +73,85 @@ typedef struct {
   BOARD_INIT  BoardInitEndOfFirmware;
 } BOARD_NOTIFICATION_INIT_FUNC;
 
+/**
+  Registers the given function for callback during board detection.
+
+  When this function is called the given function pointer is added to an 
internal list. When board detection is
+  performed within the BoardDetect() API, the function pointers in the list 
will be invoked until a board
+  detection function reports it has successfully detected the board.
+
+  @param[in]BoardDetect A pointer to a function of type 
BOARD_DETECT_FUNC that is called during
+board detection.
+
+  @retval   EFI_SUCCESS The function was successfully 
registered.
+  @retval   EFI_INVALID_PARAMETER   The function pointer given is NULL.
+  @retval   EFI_OUT_OF_RESOURCESInsufficient memory resources exist to 
add a new board detection callback.
+
+**/
 EFI_STATUS
 EFIAPI
 RegisterBoardDetect (
   IN BOARD_DETECT_FUNC  *BoardDetect
   );
 
+/**
+  Registers the given set of board functions for callback to perform 
pre-memory board initialization tasks.
+
+  When this function is called, the given structure of function pointers are 
stored for future invocation. When
+  board pre-memory initialization tasks are required, the corresponding 
pre-memory function in this structure
+  will be called. Typically, RegisterBoardPreMemInit() is called during board 
detection with the successfully
+  detected board providing its set of board-specific pre-memory initialization 
functions.
+
+  @param[in]BoardPreMemInit A pointer to a structure of function 
pointers described in the type
+BOARD_PRE_MEM_INIT_FUNC.
+
+  @retval   EFI_SUCCESS The board pre-memory functions were 
successfully registered.
+  @retval   EFI_INVALID_PARAMETER   The pointer given is NULL.
+  @retval   EFI_OUT_OF_RESOURCESInsufficient memory resources exist to 
register the callback functions.
+
+**/
 EFI_STATUS
 EFIAPI
 RegisterBoardPreMemInit (
   IN BOARD_PRE_MEM_INIT_FUNC  *BoardPreMemInit
   );
 
+/**
+  Registers the given set of board functions for callback to perform 
post-memory board initialization tasks.
+
+  When this function is called, the given structure of function pointers are 
stored for future invocation. When
+  board post-memory initialization tasks are required, the corresponding 
post-memory function in this structure
+  will be called. Typically, RegisterBoardPostMemInit() is called during board 
detection with the successfuly
+  detected board providing its set of board-specific post-memory 
initialization functions.
+
+  @param[in]BoardPostMemInitA pointer to a structure of function 
pointers described in the type
+BOARD_POST_MEM_INIT_FUNC.
+
+  @retval