[U-Boot] [PATCH 1/2] fdtdec: test: Fix memory leak

Thierry Reding thierry.reding at gmail.com
Mon May 20 16:05:04 UTC 2019


From: Thierry Reding <treding at nvidia.com>

Free the memory allocated to store the test FDT upon test completion to
avoid leaking the memory. We don't bother cleaning up on test failure
since the code is broken in that case and should be fixed, in which case
the leak would also go away.

Reported-by: Tom Rini <tom.rini at gmail.com>
Suggested-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
Signed-off-by: Thierry Reding <treding at nvidia.com>
---
 lib/fdtdec_test.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/fdtdec_test.c b/lib/fdtdec_test.c
index f6defe16c5a6..54efcc3d46ac 100644
--- a/lib/fdtdec_test.c
+++ b/lib/fdtdec_test.c
@@ -138,6 +138,7 @@ static int run_test(const char *aliases, const char *nodes, const char *expect)
 	}
 
 	printf("pass\n");
+	free(blob);
 	return 0;
 }
 
@@ -288,6 +289,7 @@ static int check_carveout(void)
 	CHECKVAL(make_fdt_carveout(fdt, FDT_SIZE, 2, 2), 0);
 	CHECKOK(check_fdt_carveout(fdt, 2, 2));
 
+	free(fdt);
 	return 0;
 }
 
-- 
2.21.0



More information about the U-Boot mailing list