diff mbox series

bootstd: Fix a memory leak in the efi manager bootflow

Message ID 20231207092012.17914-1-ilias.apalodimas@linaro.org
State Superseded
Headers show
Series bootstd: Fix a memory leak in the efi manager bootflow | expand

Commit Message

Ilias Apalodimas Dec. 7, 2023, 9:20 a.m. UTC
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@linaro.org>
---
 boot/bootmeth_efi_mgr.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Ilias Apalodimas Dec. 7, 2023, 9:26 a.m. UTC | #1
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@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@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
>
diff mbox series

Patch

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;
 	}