Skip to contentSkip to conversation

powerpc/512x: Hold the reference returned by of_find_compatible_node

PATCH Applied Liang He 2 participants 2 messages Jun 21, 2022 – Sep 9, 2022

Subsystems (2)
lore
Share & tools
lore

Liang He

author
#0 lore raw

PATCH 1/1 powerpc/512x: Hold the reference returned by of_find_compatible_node

In mpc5121_clk_provide_migration_support(), we need to hold the reference returned by of_find_compatible_node() and use it to call of_node_put for refcount balance.

---
 arch/powerpc/platforms/512x/clock-commonclk.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
arch/powerpc/platforms/512x/clock-commonclk.c +4 -2
index ca475462e95b..42abeba4f698 100644
@@ -950,7 +950,7 @@ static void __init mpc5121_clk_register_of_provider(struct device_node *np)
  */
 static void __init mpc5121_clk_provide_migration_support(void)
 {
-
+	struct device_node *np;
 	/*
 	 * pre-enable those clock items which are not yet appropriately
 	 * acquired by their peripheral driver
@@ -970,7 +970,9 @@ static void __init mpc5121_clk_provide_migration_support(void)
 	 * unused and so it gets disabled
 	 */
 	clk_prepare_enable(clks[MPC512x_CLK_PSC3_MCLK]);/* serial console */
-	if (of_find_compatible_node(NULL, "pci", "fsl,mpc5121-pci"))
+	np = of_find_compatible_node(NULL, "pci", "fsl,mpc5121-pci");
+	of_node_put(np);
+	if (np)
 		clk_prepare_enable(clks[MPC512x_CLK_PCI]);
 }
 
Signature · 1 line
2.25.1