[PATCH 1/1] efi_loader: fix efi_initrd_deregister()

Ilias Apalodimas ilias.apalodimas at linaro.org
Fri Sep 30 08:15:00 CEST 2022


Hi Heinrich

On Fri, 30 Sept 2022 at 02:58, Heinrich Schuchardt
<heinrich.schuchardt at canonical.com> wrote:
>
> Don't try to delete a non-existent handle.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
> ---
>  lib/efi_loader/efi_load_initrd.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/lib/efi_loader/efi_load_initrd.c b/lib/efi_loader/efi_load_initrd.c
> index c5e6652e66..3d6044f760 100644
> --- a/lib/efi_loader/efi_load_initrd.c
> +++ b/lib/efi_loader/efi_load_initrd.c
> @@ -230,6 +230,9 @@ efi_status_t efi_initrd_register(void)
>   */
>  void efi_initrd_deregister(void)
>  {
> +       if (!efi_initrd_handle)
> +               return;
> +

I am not sure what we gain with this.  efi_delete_handle() won't run
anyway since it will return EFI_INVALID_PARAMETER no?
I think the rabbit hole is a bit deeper here.  I would like to forbid
users calling efi_delete_handle().   In theory and if we want be
pedantic on the EFI spec, we should only use Install/UninstallProtocol
(or even better the multiple variant since it's the only one that
checks for duplicate DPs according to the spec) and have the
UninstallProtocol check if there are remaining protocols in the
handle.  If there aren't we should delete the handle as well.

Regards
/Ilias
>         efi_delete_handle(efi_initrd_handle);
>         efi_initrd_handle = NULL;
>  }
> --
> 2.37.2
>


More information about the U-Boot mailing list