[PATCH] commands: oftree: fix memory leak

Sascha Hauer s.hauer at pengutronix.de
Thu Nov 27 00:04:54 PST 2025


The fdt allocated with of_get_flattened_tree() is never freed, add
missing free() after usage.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 commands/oftree.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/commands/oftree.c b/commands/oftree.c
index b172aee9e0..53ca44bb86 100644
--- a/commands/oftree.c
+++ b/commands/oftree.c
@@ -74,6 +74,8 @@ static int do_oftree(int argc, char *argv[])
 
 		ret = write_file(save, fdt, fdt32_to_cpu(fdt->totalsize));
 
+		free(fdt);
+
 		goto out;
 	}
 
-- 
2.47.3




More information about the barebox mailing list