Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu...@intel.com>
Cc: Jaben Carsey <jaben.car...@intel.com>
---
 ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c 
b/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c
index 609d076..0d12f01 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c
@@ -2,7 +2,7 @@
   Main file for DrvCfg shell Driver1 function.
 
   (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
-  Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -57,8 +57,11 @@ FindHiiHandleViaDevPath(
   Status = HiiDb->ListPackageLists(HiiDb, EFI_HII_PACKAGE_DEVICE_PATH, NULL, 
&HandleBufferSize, HandleBuffer);
   if (Status == EFI_BUFFER_TOO_SMALL) {
     HandleBuffer = AllocateZeroPool(HandleBufferSize);
-    ASSERT (HandleBuffer != NULL);
-    Status = HiiDb->ListPackageLists(HiiDb, EFI_HII_PACKAGE_DEVICE_PATH, NULL, 
&HandleBufferSize, HandleBuffer);
+    if (HandleBuffer == NULL) {
+      Status = EFI_OUT_OF_RESOURCES;
+    } else {
+      Status = HiiDb->ListPackageLists (HiiDb, EFI_HII_PACKAGE_DEVICE_PATH, 
NULL, &HandleBufferSize, HandleBuffer);
+    }
   }
   if (EFI_ERROR(Status)) {
     SHELL_FREE_NON_NULL(HandleBuffer);
@@ -75,8 +78,12 @@ FindHiiHandleViaDevPath(
     Status = HiiDb->ExportPackageLists(HiiDb, HandleBuffer[LoopVariable], 
&MainBufferSize, MainBuffer);
     if (Status == EFI_BUFFER_TOO_SMALL) {
       MainBuffer = AllocateZeroPool(MainBufferSize);
-      ASSERT (MainBuffer != NULL);
-      Status = HiiDb->ExportPackageLists(HiiDb, HandleBuffer[LoopVariable], 
&MainBufferSize, MainBuffer);
+      if (MainBuffer != NULL) {
+        Status = HiiDb->ExportPackageLists (HiiDb, HandleBuffer[LoopVariable], 
&MainBufferSize, MainBuffer);
+      }
+    }
+    if (EFI_ERROR (Status)) {
+      continue;
     }
     //
     // Enumerate through the block of returned memory.
-- 
2.9.0.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to