[PATCH master 28/39] efi: loader: fix memory leak of variable file buffer on success
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Feb 16 00:44:28 PST 2026
efi_var_from_file() returns EFI_SUCCESS directly without freeing the
buf allocated by read_fd(). The free only happens on the error path.
Use the common error label for both paths so buf is always freed.
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 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/efi/loader/efi_var_file.c b/efi/loader/efi_var_file.c
index c0150baa27ac..12543bce2851 100644
--- a/efi/loader/efi_var_file.c
+++ b/efi/loader/efi_var_file.c
@@ -180,7 +180,7 @@ efi_status_t efi_var_from_file(int dirfd, const char *filename)
goto error;
}
- return EFI_SUCCESS;
+ ret = EFI_SUCCESS;
error:
free(buf);
return ret;
--
2.47.3
More information about the barebox
mailing list