MdeModulePkg/BootMaintUi: Add error handling codes when AllocatePool fail
The AllocateCopyPool in function ExtractFileNameFromDevicePath may return NULL, so need to do error handling. This patch is to add error handling codes for function ExtractFileNameFromDevicePath and its caller functions. Cc: Eric Dong <eric.dong@intel.com> Cc: Hao Wu <hao.a.wu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Hao Wu <hao.a.wu@intel.com>
This commit is contained in:
@@ -865,29 +865,33 @@ BootFromFile (
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
|
||||
CHAR16 *FileName;
|
||||
|
||||
FileName = NULL;
|
||||
|
||||
FileName = ExtractFileNameFromDevicePath(FilePath);
|
||||
EfiBootManagerInitializeLoadOption (
|
||||
&BootOption,
|
||||
0,
|
||||
LoadOptionTypeBoot,
|
||||
LOAD_OPTION_ACTIVE,
|
||||
FileName,
|
||||
FilePath,
|
||||
NULL,
|
||||
0
|
||||
);
|
||||
//
|
||||
// Since current no boot from removable media directly is allowed */
|
||||
//
|
||||
gST->ConOut->ClearScreen (gST->ConOut);
|
||||
if (FileName != NULL) {
|
||||
EfiBootManagerInitializeLoadOption (
|
||||
&BootOption,
|
||||
0,
|
||||
LoadOptionTypeBoot,
|
||||
LOAD_OPTION_ACTIVE,
|
||||
FileName,
|
||||
FilePath,
|
||||
NULL,
|
||||
0
|
||||
);
|
||||
//
|
||||
// Since current no boot from removable media directly is allowed */
|
||||
//
|
||||
gST->ConOut->ClearScreen (gST->ConOut);
|
||||
|
||||
BmmSetConsoleMode (FALSE);
|
||||
EfiBootManagerBoot (&BootOption);
|
||||
BmmSetConsoleMode (TRUE);
|
||||
BmmSetConsoleMode (FALSE);
|
||||
EfiBootManagerBoot (&BootOption);
|
||||
BmmSetConsoleMode (TRUE);
|
||||
|
||||
FreePool(FileName);
|
||||
FreePool(FileName);
|
||||
|
||||
EfiBootManagerFreeLoadOption (&BootOption);
|
||||
EfiBootManagerFreeLoadOption (&BootOption);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user