[PATCH master 31/39] efi: payload: fix possible memory leaks during init
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Feb 16 00:44:31 PST 2026
efi_get_boot(): buf from efi_get_global_var() is never freed after
parsing the Boot variable. Add free(buf) before return.
efi_late_init(): the flat DTB blob from read_file() is never freed
after of_unflatten_dtb() creates the unflattened tree. Free it
immediately after unflattening.
Co-Authored-By: Claude Opus 4.6 <noreply at anthropic.com>
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
efi/payload/init.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/efi/payload/init.c b/efi/payload/init.c
index f74ac4966fb1..03f831840de7 100644
--- a/efi/payload/init.c
+++ b/efi/payload/init.c
@@ -96,6 +96,8 @@ static struct efi_boot *efi_get_boot(int num)
printf("path: %s\n", device_path_to_str(boot->path, true));
+ free(buf);
+
return boot;
}
@@ -301,6 +303,8 @@ static int efi_late_init(void)
}
state_root = of_unflatten_dtb(fdt, size);
+ free(fdt);
+
if (!IS_ERR(state_root)) {
struct device_node *np = NULL;
struct state *state;
--
2.47.3
More information about the barebox
mailing list