[Concept,24/33] test: dm: Dispose tree in oftree_new

Message ID 20260416023021.626949-25-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>

The oftree_new test allocates a live tree via oftree_new() and never
disposes of it. Release the root on exit so the test-local tree is
cleaned up.

Note: of_live_free() currently only frees the root node, so subnodes
added via ofnode_add_subnode() still leak. We'll deal with that later.

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 516e24ceb28..838a216cfa9 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -1510,6 +1510,8 @@  static int dm_test_oftree_new(struct unit_test_state *uts)
 	check = ofnode_find_subnode(node, "edmund");
 	ut_asserteq(check.of_offset, subnode.of_offset);
 
+	oftree_dispose(tree);
+
 	return 0;
 }
 DM_TEST(dm_test_oftree_new, UTF_SCAN_FDT);