Reviewed-by: Ruiyu Ni <[email protected]>

-----Original Message-----
From: Qiu, Shumin 
Sent: Friday, December 11, 2015 2:42 PM
To: [email protected]
Cc: Qiu, Shumin <[email protected]>; Carsey, Jaben <[email protected]>; 
Ni, Ruiyu <[email protected]>
Subject: [PATCH] ShellPkg: Initialize the local pointer to avoid potential 
suspicious dereference.

1. Initialize the local pointer 'HandleBuffer'.
2. When 'LocateHandleBuffer' return error 'HandleBuffer' is expected unchanged, 
add code make sure this.

Cc: Jaben Carsey <[email protected]>
Cc: Ruiyu Ni <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <[email protected]>
---
 ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c
index 3f08cc8..7b26e4d 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c
@@ -317,6 +317,7 @@ ShellMmLocateIoProtocol (
   }
 
   *PciRootBridgeIo = NULL;
+  HandleBuffer     = NULL;
   Status = gBS->LocateHandleBuffer (
                   ByProtocol,
                   &gEfiPciRootBridgeIoProtocolGuid,
@@ -324,7 +325,7 @@ ShellMmLocateIoProtocol (
                   &HandleCount,
                   &HandleBuffer
                   );
-  if (EFI_ERROR (Status) || (HandleCount == 0)) {
+  if (EFI_ERROR (Status) || (HandleCount == 0) || (HandleBuffer == NULL)) {
     return FALSE;
   }
 
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to