[Concept,26/33] test: dm: Release resources in oftree_to_fdt(() test

Message ID 20260416023021.626949-27-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 allocates two abufs via oftree_to_fdt() and a live tree via
oftree_from_fdt(), but never frees them, leaking about 200K each time
the test runs.

Dispose of the live tree and uninit the abufs at the end of the test.

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

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

Patch

diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index 3fd3b8509f9..68e436da929 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -1629,6 +1629,10 @@  static int dm_test_oftree_to_fdt(struct unit_test_state *uts)
 	ut_asserteq(abuf_size(&buf), abuf_size(&buf2));
 	ut_asserteq_mem(abuf_data(&buf), abuf_data(&buf2), abuf_size(&buf));
 
+	oftree_dispose(check);
+	abuf_uninit(&buf);
+	abuf_uninit(&buf2);
+
 	return 0;
 }
 DM_TEST(dm_test_oftree_to_fdt, UTF_SCAN_FDT);