[PATCH] of: unittest: fix node leak in of_dma_get_max_cpu_address test
From: Wentao Liang
Date: Tue Nov 03 2026 - 08:09:18 EST
of_find_node_by_path() returns a device_node with its reference count
incremented. of_unittest_dma_get_max_cpu_address() passes the node to
of_dma_get_max_cpu_address(), which does not consume the reference, and
then returns without dropping it.
Release the reference after the check.
Fixes: 07d13a1d6120 ("of: unittest: Add test for of_dma_get_max_cpu_address()")
Cc: stable@xxxxxxxxxxxxxxx
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
drivers/of/unittest.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index d2f5c7ef3178..8133c954d335 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -1145,6 +1145,7 @@ 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