diff mbox series

[v2,1/2] OPP: Fix refcount leak bug for opp_table

Message ID 20220718133632.937290-1-windhl@126.com
State New
Headers show
Series [v2,1/2] OPP: Fix refcount leak bug for opp_table | expand

Commit Message

Liang He July 18, 2022, 1:36 p.m. UTC
In _of_init_opp_table(), of_put_node() in the last line is not
needed as the 'opp_np' is escaped out into 'opp_table->np' and
’opp_table' is an out parameter. We should call the of_node_put()
when the 'opp_table' is released in _opp_table_kref_release().

Signed-off-by: Liang He <windhl@126.com>
---
 changelog:

 v2: (1) add the of_node_put() in _opp_table_kref_release()
     (2) rebase on linux-next/master
     (3) split v1 into two commits, opp_table->np and opp->np
 v1: https://lore.kernel.org/all/20220715144712.444104-1-windhl@126.com/


 drivers/opp/core.c | 1 +
 drivers/opp/of.c   | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index 4f4a285886fa..cc2671322e41 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -1499,6 +1499,7 @@  static void _opp_table_kref_release(struct kref *kref)
 		dev_pm_opp_put(opp_table->current_opp);
 
 	_of_clear_opp_table(opp_table);
+	of_node_put(opp_table->np);
 
 	/* Release automatically acquired single clk */
 	if (!IS_ERR(opp_table->clk))
diff --git a/drivers/opp/of.c b/drivers/opp/of.c
index 8367823a2001..374544afe9e4 100644
--- a/drivers/opp/of.c
+++ b/drivers/opp/of.c
@@ -242,7 +242,6 @@  void _of_init_opp_table(struct opp_table *opp_table, struct device *dev,
 	opp_table->np = opp_np;
 
 	_opp_table_alloc_required_tables(opp_table, dev, opp_np);
-	of_node_put(opp_np);
 }
 
 void _of_clear_opp_table(struct opp_table *opp_table)