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

Wentao Liang posted 1 patch 1 week ago
drivers/of/unittest.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] of: unittest: Fix np reference leak in of_unittest_dma_ranges_one()
Posted by Wentao Liang 1 week ago
When the bogus device allocation fails the function returns early and
never drops the reference obtained from of_find_node_by_path(). Add the
missing of_node_put() so the node reference is not leaked.

Fixes: a8d61a9112ad ("of: unittest: fix warning on PowerPC frame size warning")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/of/unittest.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index d1a88a043300..226debdaa5c1 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -1141,6 +1141,7 @@ static void __init of_unittest_dma_ranges_one(const char *path,
 		if (!dev_bogus) {
 			unittest(0, "kzalloc() failed\n");
 			kfree(map);
+			of_node_put(np);
 			return;
 		}
 
-- 
2.34.1