summaryrefslogtreecommitdiff
path: root/ShellPkg/Library/UefiShellDriver1CommandsLib
diff options
context:
space:
mode:
authorRuiyu Ni <ruiyu.ni@intel.com>2016-07-13 15:44:23 +0800
committerHao Wu <hao.a.wu@intel.com>2016-07-25 11:04:44 +0800
commitd32e3a0bc63d3bd15aa1fa5f708d71fcab57ea90 (patch)
tree55b37cb95bdb03802170c73f2a47fb43993d3085 /ShellPkg/Library/UefiShellDriver1CommandsLib
parent90604964ce730e9656d83c2da013381c25042d4c (diff)
downloadedk2-platforms-d32e3a0bc63d3bd15aa1fa5f708d71fcab57ea90.tar.xz
ShellPkg/DrvCfg: Handle memory allocation failure
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> (cherry picked from commit 58972f5cf7e1163e474f961afe34e200fd5dac11)
Diffstat (limited to 'ShellPkg/Library/UefiShellDriver1CommandsLib')
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c
index 609d076da0..0d12f01199 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.