diff mbox series

efi_loader: fix memory freeing in efi_get_dp_from_boot()

Message ID 20240812205759.1732217-1-ilias.apalodimas@linaro.org
State Accepted
Commit 3a8ad050aa8b1663316952d1d4bebdb5f4911160
Headers show
Series efi_loader: fix memory freeing in efi_get_dp_from_boot() | expand

Commit Message

Ilias Apalodimas Aug. 12, 2024, 8:57 p.m. UTC
efi_get_var() allocates memory which must be freed after the variable is
used. Since the device path is duplicated after we deserialize the load
options free the memory used for the variable payload

Fixes: db61e70e0d2a efi_loader: efi_dp_from_lo() should skip VenMedia node
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
 lib/efi_loader/efi_helper.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Simon Glass Sept. 1, 2024, 8:10 p.m. UTC | #1
On Mon, 12 Aug 2024 at 14:58, Ilias Apalodimas
<ilias.apalodimas@linaro.org> wrote:
>
> efi_get_var() allocates memory which must be freed after the variable is
> used. Since the device path is duplicated after we deserialize the load
> options free the memory used for the variable payload
>
> Fixes: db61e70e0d2a efi_loader: efi_dp_from_lo() should skip VenMedia node
> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> ---
>  lib/efi_loader/efi_helper.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c
index 65d2116381ae..916f43da26c7 100644
--- a/lib/efi_loader/efi_helper.c
+++ b/lib/efi_loader/efi_helper.c
@@ -74,6 +74,7 @@  out:
  */
 struct efi_device_path *efi_get_dp_from_boot(const efi_guid_t *guid)
 {
+	struct efi_device_path *file_path = NULL;
 	struct efi_load_option lo;
 	void *var_value;
 	efi_uintn_t size;
@@ -92,11 +93,11 @@  struct efi_device_path *efi_get_dp_from_boot(const efi_guid_t *guid)
 	if (ret != EFI_SUCCESS)
 		goto err;
 
-	return efi_dp_from_lo(&lo, guid);
+	file_path = efi_dp_from_lo(&lo, guid);
 
 err:
 	free(var_value);
-	return NULL;
+	return file_path;
 }
 
 /**