[PATCH] bootstd: Fix a memory leak in the efi manager bootflow

Ilias Apalodimas ilias.apalodimas at linaro.org
Thu Dec 7 10:26:46 CET 2023


The patch is needed, but I forgot to include malloc.h, I'll send a v2 later

Thanks
/Ilias

On Thu, 7 Dec 2023 at 11:20, Ilias Apalodimas
<ilias.apalodimas at linaro.org> wrote:
>
> efi_get_var() allocates memory which has to be freed after the value of
> the variable is consumed. Free the memory properly
>
> Fixes: f2bfa0cb1794 ("bootstd: Make efi_mgr bootmeth work for non-sandbox setups")
> Signed-off-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>
> ---
>  boot/bootmeth_efi_mgr.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/boot/bootmeth_efi_mgr.c b/boot/bootmeth_efi_mgr.c
> index e6c42d41fb80..530ad09cce83 100644
> --- a/boot/bootmeth_efi_mgr.c
> +++ b/boot/bootmeth_efi_mgr.c
> @@ -65,6 +65,7 @@ static int efi_mgr_read_bootflow(struct udevice *dev, struct bootflow *bflow)
>         bootorder = efi_get_var(u"BootOrder", &efi_global_variable_guid,
>                                 &size);
>         if (bootorder) {
> +               free(bootorder);
>                 bflow->state = BOOTFLOWST_READY;
>                 return 0;
>         }
> --
> 2.40.1
>


More information about the U-Boot mailing list