[PATCH] bus: vexpress-config: Fix refcount leak in vexpress_syscfg_probe

Miaoqian Lin linmq006 at gmail.com
Thu Jun 2 04:24:26 PDT 2022


of_parse_phandle() returns a node pointer with refcount
incremented, we should use of_node_put() on it when not need anymore.
Add missing of_node_put() to avoid refcount leak.

Fixes: a5a38765ac79 ("bus: vexpress-config: simplify config bus probing")
Signed-off-by: Miaoqian Lin <linmq006 at gmail.com>
---
 drivers/bus/vexpress-config.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/vexpress-config.c b/drivers/bus/vexpress-config.c
index a58ac0c8e282..b368e2f01f8b 100644
--- a/drivers/bus/vexpress-config.c
+++ b/drivers/bus/vexpress-config.c
@@ -395,10 +395,13 @@ static int vexpress_syscfg_probe(struct platform_device *pdev)
 		struct device_node *bridge_np;
 
 		bridge_np = of_parse_phandle(node, "arm,vexpress,config-bridge", 0);
-		if (bridge_np != pdev->dev.parent->of_node)
+		if (bridge_np != pdev->dev.parent->of_node) {
+			of_node_put(bridge_np);
 			continue;
+		}
 
 		of_platform_populate(node, NULL, NULL, &pdev->dev);
+		of_node_put(bridge_np);
 	}
 
 	return 0;
-- 
2.25.1




More information about the linux-arm-kernel mailing list