[Concept,23/33] test: dm: Dispose tree in livetree_ensure()

Message ID 20260416023021.626949-24-sjg@u-boot.org
State New
Headers
Series Fix memory leaks and test pollution in sandbox tests |

Commit Message

Simon Glass April 16, 2026, 2:29 a.m. UTC
  From: Simon Glass <sjg@chromium.org>

This dm_test_oftree_new() test unflattens a secondary device tree using
oftree_from_fdt() but never frees it, thus leaking about 6K of memory
per run.

Dispose of the tree before returning.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 test/dm/ofnode.c | 2 ++
 1 file changed, 2 insertions(+)
  

Patch

diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index 0f60c2a6281..516e24ceb28 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -1492,6 +1492,8 @@  static int dm_test_livetree_ensure(struct unit_test_state *uts)
 	ut_asserteq_str("sandbox-other2",
 			ofnode_read_string(node, "compatible"));
 
+	oftree_dispose(tree);
+
 	return 0;
 }
 DM_TEST(dm_test_livetree_ensure, UTF_SCAN_FDT);