[PATCH] of: unittest: Fix of_symbols reference leak in of_unittest_overlay_high_level()

From: Wentao Liang

Date: Thu Sep 17 2026 - 10:25:10 EST


of_get_child_by_name() returns a node with an elevated reference count,
but the function never drops it: neither on the early return for an
illegal node name, nor on the normal return, nor on the err_unlock
path. Add the missing of_node_put() calls.

Fixes: 81d0848fc8d2 ("of: Add unit tests for applying overlays")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
drivers/of/unittest.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 900840850814..36c64d485a53 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -4091,6 +4091,7 @@ static __init void of_unittest_overlay_high_level(void)
np);
of_node_put(np);
of_node_put(base_child);
+ of_node_put(of_symbols);
return;
}
}
@@ -4289,10 +4290,13 @@ static __init void of_unittest_overlay_high_level(void)
EXPECT_END(KERN_ERR,
"OF: resolver: node label 'this_label_does_not_exist' not found in live devicetree symbols table");

+ of_node_put(of_symbols);
+
return;

err_unlock:
mutex_unlock(&of_mutex);
+ of_node_put(of_symbols);
}

static int of_unittest_pci_dev_num;
--
2.34.1