[PATCH] of: unittest: Fix np reference leak in of_unittest_dma_get_max_cpu_address()

From: Wentao Liang

Date: Thu Sep 17 2026 - 09:54:11 EST


of_find_node_by_path() returns a node with an elevated reference count,
but the function never drops it. Add the missing of_node_put() before
returning so that the reference is not leaked.

Fixes: 07d13a1d6120 ("of: unittest: Add test for of_dma_get_max_cpu_address()")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
drivers/of/unittest.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 5259c45e355d..d1a88a043300 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -1110,6 +1110,8 @@ static void __init of_unittest_dma_get_max_cpu_address(void)
unittest(cpu_addr == 0x4fffffff,
"of_dma_get_max_cpu_address: wrong CPU addr %pad (expecting %x)\n",
&cpu_addr, 0x4fffffff);
+
+ of_node_put(np);
}

static void __init of_unittest_dma_ranges_one(const char *path,
--
2.34.1