[PATCH v2] efi_loader: do not install dtb if bootmgr fails

Ilias Apalodimas ilias.apalodimas at linaro.org
Thu Apr 25 10:10:11 CEST 2024


Hi Heinrich,

On Thu, 25 Apr 2024 at 11:06, Heinrich Schuchardt
<heinrich.schuchardt at canonical.com> wrote:
>
> If the UEFI boot manager fails there is no point in installing the
> device-tree as a configuration table.
>
> Unload image if device-tree cannot be installed.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
> ---
> v2:
>         Unload image if device-tree cannot be installed.
> ---
>  lib/efi_loader/efi_bootmgr.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c
> index ca2ebdaa32f..aa2cc0eb52f 100644
> --- a/lib/efi_loader/efi_bootmgr.c
> +++ b/lib/efi_loader/efi_bootmgr.c
> @@ -1209,15 +1209,21 @@ efi_status_t efi_bootmgr_run(void *fdt)
>                 return CMD_RET_FAILURE;
>         }
>
> -       ret = efi_install_fdt(fdt);
> -       if (ret != EFI_SUCCESS)
> -               return ret;
> -
>         ret = efi_bootmgr_load(&handle, &load_options);
>         if (ret != EFI_SUCCESS) {
>                 log_notice("EFI boot manager: Cannot load any image\n");
>                 return ret;
>         }
>
> +       ret = efi_install_fdt(fdt);
> +       if (ret != EFI_SUCCESS) {
> +               if (EFI_CALL(efi_unload_image(*handle)) == EFI_SUCCESS)
> +                       free(load_options);
> +               else
> +                       log_err("Unloading image failed\n");
> +
> +               return ret;
> +       }
> +

This should be fine, I was just wondering, why not leave the
efi_install_fdt() and uninstall it if efi_bootmgr_load() fails.
That would remove the unload complexity if the fdt install fails.

Thanks
/Ilias

>         return do_bootefi_exec(handle, load_options);
>  }
> --
> 2.43.0
>


More information about the U-Boot mailing list