MdeModulePkg: Fix conditionally uninitialized variables
Fixes CodeQL alerts for CWE-457: https://cwe.mitre.org/data/definitions/457.html Cc: Dandan Bi <dandan.bi@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Erich McMillan <emcmillan@microsoft.com> Cc: Guomin Jiang <guomin.jiang@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Michael Kubacki <mikuback@linux.microsoft.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Co-authored-by: Erich McMillan <emcmillan@microsoft.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn> Reviewed-by: Oliver Smith-Denny <osd@smith-denny.com>
This commit is contained in:
committed by
mergify[bot]
parent
84d77d9bf5
commit
07251f3c6a
@@ -691,6 +691,7 @@ BdsEntry (
|
||||
EFI_DEVICE_PATH_PROTOCOL *FilePath;
|
||||
EFI_STATUS BootManagerMenuStatus;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION PlatformDefaultBootOption;
|
||||
BOOLEAN PlatformDefaultBootOptionValid;
|
||||
|
||||
HotkeyTriggered = NULL;
|
||||
Status = EFI_SUCCESS;
|
||||
@@ -809,24 +810,24 @@ BdsEntry (
|
||||
CpuDeadLoop ();
|
||||
}
|
||||
|
||||
Status = EfiBootManagerInitializeLoadOption (
|
||||
&PlatformDefaultBootOption,
|
||||
LoadOptionNumberUnassigned,
|
||||
LoadOptionTypePlatformRecovery,
|
||||
LOAD_OPTION_ACTIVE,
|
||||
L"Default PlatformRecovery",
|
||||
FilePath,
|
||||
NULL,
|
||||
0
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
PlatformDefaultBootOptionValid = EfiBootManagerInitializeLoadOption (
|
||||
&PlatformDefaultBootOption,
|
||||
LoadOptionNumberUnassigned,
|
||||
LoadOptionTypePlatformRecovery,
|
||||
LOAD_OPTION_ACTIVE,
|
||||
L"Default PlatformRecovery",
|
||||
FilePath,
|
||||
NULL,
|
||||
0
|
||||
) == EFI_SUCCESS;
|
||||
ASSERT (PlatformDefaultBootOptionValid == TRUE);
|
||||
|
||||
//
|
||||
// System firmware must include a PlatformRecovery#### variable specifying
|
||||
// a short-form File Path Media Device Path containing the platform default
|
||||
// file path for removable media if the platform supports Platform Recovery.
|
||||
//
|
||||
if (PcdGetBool (PcdPlatformRecoverySupport)) {
|
||||
if (PlatformDefaultBootOptionValid && PcdGetBool (PcdPlatformRecoverySupport)) {
|
||||
LoadOptions = EfiBootManagerGetLoadOptions (&LoadOptionCount, LoadOptionTypePlatformRecovery);
|
||||
if (EfiBootManagerFindLoadOption (&PlatformDefaultBootOption, LoadOptions, LoadOptionCount) == -1) {
|
||||
for (Index = 0; Index < LoadOptionCount; Index++) {
|
||||
@@ -1104,15 +1105,17 @@ BdsEntry (
|
||||
LoadOptions = EfiBootManagerGetLoadOptions (&LoadOptionCount, LoadOptionTypePlatformRecovery);
|
||||
ProcessLoadOptions (LoadOptions, LoadOptionCount);
|
||||
EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount);
|
||||
} else {
|
||||
} else if (PlatformDefaultBootOptionValid) {
|
||||
//
|
||||
// When platform recovery is not enabled, still boot to platform default file path.
|
||||
//
|
||||
EfiBootManagerProcessLoadOption (&PlatformDefaultBootOption);
|
||||
PlatformDefaultBootOptionValid = EfiBootManagerProcessLoadOption (&PlatformDefaultBootOption) == EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
EfiBootManagerFreeLoadOption (&PlatformDefaultBootOption);
|
||||
if (PlatformDefaultBootOptionValid) {
|
||||
EfiBootManagerFreeLoadOption (&PlatformDefaultBootOption);
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_ERROR, "[Bds] Unable to boot!\n"));
|
||||
PlatformBootManagerUnableToBoot ();
|
||||
|
Reference in New Issue
Block a user