GroupMultipleLegacyBootOption4SameType ASSERTs with EFI_NOT_FOUND when the BootOrder variable is not found. This occurs because BootOrderSize is zero and BootOrder is NULL. This patch eliminates the two ASSERTs which occur.
Change-Id: I6b4f713575011da7c7442fe25ebdbd8379b0303b Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Lee Leahy <[email protected]> --- .../Universal/BdsDxe/BootMaint/BBSsupport.c | 41 ++++++++++++---------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c index 6a0b525..379a951 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c @@ -53,9 +53,9 @@ OrderLegacyBootOption4SameType ( UINTN BootOrderSize; UINTN Index; UINTN StartPosition; - + BDS_COMMON_OPTION *BootOption; - + CHAR16 OptionName[sizeof ("Boot####")]; UINT16 *BbsIndexArray; UINT16 *DeviceTypeArray; @@ -82,12 +82,12 @@ OrderLegacyBootOption4SameType ( ASSERT (*DisBootOption != NULL); for (Index = 0; Index < BootOrderSize / sizeof (UINT16); Index++) { - + UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", BootOrder[Index]); InitializeListHead (&List); BootOption = BdsLibVariableToOption (&List, OptionName); ASSERT (BootOption != NULL); - + if ((DevicePathType (BootOption->DevicePath) == BBS_DEVICE_PATH) && (DevicePathSubType (BootOption->DevicePath) == BBS_BBS_DP)) { // @@ -119,7 +119,7 @@ OrderLegacyBootOption4SameType ( if (BbsIndexArray[Index] == (DevOrder[DevOrderCount] & 0xFF)) { StartPosition = MIN (StartPosition, Index); NewBootOption[DevOrderCount] = BootOrder[Index]; - + if ((DevOrder[DevOrderCount] & 0xFF00) == 0xFF00) { (*DisBootOption)[*DisBootOptionCount] = BootOrder[Index]; (*DisBootOptionCount)++; @@ -157,7 +157,7 @@ OrderLegacyBootOption4SameType ( /** Group the legacy boot options in the BootOption. - The routine assumes the boot options in the beginning that covers all the device + The routine assumes the boot options in the beginning that covers all the device types are ordered properly and re-position the following boot options just after the corresponding boot options with the same device type. For example: @@ -194,7 +194,6 @@ GroupMultipleLegacyBootOption4SameType ( &gEfiGlobalVariableGuid, &BootOrderSize ); - for (Index = 0; Index < BootOrderSize / sizeof (UINT16); Index++) { UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", BootOrder[Index]); InitializeListHead (&List); @@ -238,17 +237,21 @@ GroupMultipleLegacyBootOption4SameType ( FreePool (BootOption); } - Status = gRT->SetVariable ( - L"BootOrder", - &gEfiGlobalVariableGuid, - EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, - BootOrderSize, - BootOrder - ); - // - // Changing content without increasing its size with current variable implementation shouldn't fail. - // - ASSERT_EFI_ERROR (Status); - FreePool (BootOrder); + if (BootOrder != NULL) { + if (BootOrderSize != 0) { + Status = gRT->SetVariable ( + L"BootOrder", + &gEfiGlobalVariableGuid, + EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, + BootOrderSize, + BootOrder + ); + // + // Changing content without increasing its size with current variable implementation shouldn't fail. + // + ASSERT_EFI_ERROR (Status); + } + FreePool (BootOrder); + } } -- 1.9.1 _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

