[PATCH master 10/39] efi: loader: fix memory leak in efi_var_to_file
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Feb 16 00:44:10 PST 2026
On the success path, the function returns directly at line 87,
bypassing the 'out:' label where 'buf' is freed. Every successful
variable persist leaks the collected variable buffer.
Fix by setting efiret to EFI_SUCCESS and jumping to the out label.
Co-Authored-By: Claude Opus 4.6 <noreply at anthropic.com>
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
efi/loader/efi_var_file.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/efi/loader/efi_var_file.c b/efi/loader/efi_var_file.c
index e0dec999b779..c0150baa27ac 100644
--- a/efi/loader/efi_var_file.c
+++ b/efi/loader/efi_var_file.c
@@ -84,7 +84,8 @@ efi_status_t efi_var_to_file(void)
goto error;
}
- return 0;
+ efiret = EFI_SUCCESS;
+ goto out;
error:
if (efiret != EFI_SUCCESS)
--
2.47.3
More information about the barebox
mailing list