ShellPkg/DrvDiag: 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>
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
Main file for DrvDiag shell Driver1 function.
|
Main file for DrvDiag shell Driver1 function.
|
||||||
|
|
||||||
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
|
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
|
||||||
Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -94,7 +94,9 @@ DoDiagnostics (
|
|||||||
|
|
||||||
if (DriverHandle != NULL) {
|
if (DriverHandle != NULL) {
|
||||||
DriverHandleList = AllocateZeroPool(2*sizeof(EFI_HANDLE));
|
DriverHandleList = AllocateZeroPool(2*sizeof(EFI_HANDLE));
|
||||||
ASSERT(DriverHandleList!=NULL);
|
if (DriverHandleList == NULL) {
|
||||||
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
DriverHandleList[0] = DriverHandle;
|
DriverHandleList[0] = DriverHandle;
|
||||||
DriverHandleListCount = 1;
|
DriverHandleListCount = 1;
|
||||||
} else {
|
} else {
|
||||||
@ -109,7 +111,10 @@ DoDiagnostics (
|
|||||||
|
|
||||||
if (ControllerHandle != NULL) {
|
if (ControllerHandle != NULL) {
|
||||||
ControllerHandleList = AllocateZeroPool(2*sizeof(EFI_HANDLE));
|
ControllerHandleList = AllocateZeroPool(2*sizeof(EFI_HANDLE));
|
||||||
ASSERT(ControllerHandleList!=NULL);
|
if (ControllerHandleList == NULL) {
|
||||||
|
SHELL_FREE_NON_NULL (DriverHandleList);
|
||||||
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
ControllerHandleList[0] = ControllerHandle;
|
ControllerHandleList[0] = ControllerHandle;
|
||||||
ControllerHandleListCount = 1;
|
ControllerHandleListCount = 1;
|
||||||
} else {
|
} else {
|
||||||
@ -118,7 +123,11 @@ DoDiagnostics (
|
|||||||
|
|
||||||
if (ChildHandle != NULL) {
|
if (ChildHandle != NULL) {
|
||||||
ChildHandleList = AllocateZeroPool(2*sizeof(EFI_HANDLE));
|
ChildHandleList = AllocateZeroPool(2*sizeof(EFI_HANDLE));
|
||||||
ASSERT(ChildHandleList!=NULL);
|
if (ChildHandleList != NULL) {
|
||||||
|
SHELL_FREE_NON_NULL (ControllerHandleList);
|
||||||
|
SHELL_FREE_NON_NULL (DriverHandleList);
|
||||||
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
ChildHandleList[0] = ChildHandle;
|
ChildHandleList[0] = ChildHandle;
|
||||||
ChildHandleListCount = 1;
|
ChildHandleListCount = 1;
|
||||||
} else if (AllChilds) {
|
} else if (AllChilds) {
|
||||||
|
Reference in New Issue
Block a user