[Concept,25/33] test: dm: Free trees in ofnode_too_many()

Message ID 20260416023021.626949-26-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 test registers up to OFNODE_MULTI_TREE_MAX live trees, in a loop,
to hit the -EOVERFLOW path, but never calls free_oftree() on the
successfully-registered ones. Each leaks several KB per run.

Free each tree after the check.

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

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

Patch

diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index 838a216cfa9..3fd3b8509f9 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -1379,6 +1379,7 @@  static int dm_test_ofnode_too_many(struct unit_test_state *uts)
 		 */
 		if (of_live_active() || i < max_trees - 1) {
 			ut_assertok(ret);
+			free_oftree(tree);
 		} else {
 			/*
 			 * tree should be invalid when we try to register too