Skip to content

Commit 9945bc4

Browse files
raymo200915xypron
authored andcommitted
Fix incorrect return code of boot option update
Correct the return code for out-of-memory and no boot option found Signed-off-by: Raymond Mao <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]>
1 parent 339b527 commit 9945bc4

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

cmd/bootmenu.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ static struct bootmenu_data *bootmenu_create(int delay)
352352
* a architecture-specific default image name such as BOOTAA64.EFI.
353353
*/
354354
efi_ret = efi_bootmgr_update_media_device_boot_option();
355-
if (efi_ret != EFI_SUCCESS && efi_ret != EFI_NOT_FOUND)
355+
if (efi_ret != EFI_SUCCESS)
356356
goto cleanup;
357357

358358
ret = prepare_uefi_bootorder_entry(menu, &iter, &i);

cmd/eficonfig.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2314,7 +2314,7 @@ static int do_eficonfig(struct cmd_tbl *cmdtp, int flag, int argc, char *const a
23142314
return CMD_RET_FAILURE;
23152315

23162316
ret = efi_bootmgr_update_media_device_boot_option();
2317-
if (ret != EFI_SUCCESS && ret != EFI_NOT_FOUND)
2317+
if (ret != EFI_SUCCESS)
23182318
return ret;
23192319

23202320
while (1) {

lib/efi_loader/efi_bootmgr.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -660,11 +660,13 @@ efi_status_t efi_bootmgr_update_media_device_boot_option(void)
660660
NULL, &count,
661661
(efi_handle_t **)&volume_handles);
662662
if (ret != EFI_SUCCESS)
663-
return ret;
663+
goto out;
664664

665665
opt = calloc(count, sizeof(struct eficonfig_media_boot_option));
666-
if (!opt)
666+
if (!opt) {
667+
ret = EFI_OUT_OF_RESOURCES;
667668
goto out;
669+
}
668670

669671
/* enumerate all devices supporting EFI_SIMPLE_FILE_SYSTEM_PROTOCOL */
670672
ret = efi_bootmgr_enumerate_boot_option(opt, volume_handles, count);
@@ -717,5 +719,7 @@ efi_status_t efi_bootmgr_update_media_device_boot_option(void)
717719
free(opt);
718720
efi_free_pool(volume_handles);
719721

722+
if (ret == EFI_NOT_FOUND)
723+
return EFI_SUCCESS;
720724
return ret;
721725
}

0 commit comments

Comments
 (0)