cmd/bootefi: move efi_init_obj_list() to the start of do_bootefi

None of the bootefi commands can be executed if the EFI sub-system cannot
be initialized.

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
This commit is contained in:
Heinrich Schuchardt 2026-04-21 00:03:18 +02:00
parent c5230a45a7
commit 7311130b73

View File

@ -142,6 +142,14 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc,
if (argc < 2)
return CMD_RET_USAGE;
/* Initialize EFI drivers */
ret = efi_init_obj_list();
if (ret != EFI_SUCCESS) {
log_err("Error: Cannot initialize UEFI sub-system, r = %lu\n",
ret & ~EFI_ERROR_MASK);
return CMD_RET_FAILURE;
}
if (argc > 2) {
ulong rd_addr = 0;
char *end = strchr(argv[2], ':');
@ -179,14 +187,6 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc,
if (IS_ENABLED(CONFIG_CMD_BOOTEFI_SELFTEST) &&
!strcmp(argv[1], "selftest")) {
/* Initialize EFI drivers */
ret = efi_init_obj_list();
if (ret != EFI_SUCCESS) {
log_err("Error: Cannot initialize UEFI sub-system, r = %lu\n",
ret & ~EFI_ERROR_MASK);
return CMD_RET_FAILURE;
}
ret = efi_install_fdt(fdt);
if (ret != EFI_SUCCESS)
return CMD_RET_FAILURE;