public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Liang He <windhl@126.com>
To: vireshk@kernel.org, nm@ti.com, sboyd@kernel.org,
	linux-pm@vger.kernel.org, windhl@126.com
Subject: [PATCH v2 1/2] OPP: Fix refcount leak bug for opp_table
Date: Mon, 18 Jul 2022 21:36:31 +0800	[thread overview]
Message-ID: <20220718133632.937290-1-windhl@126.com> (raw)

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 --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)
-- 
2.25.1


             reply	other threads:[~2022-07-18 13:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-18 13:36 Liang He [this message]
2022-07-18 13:36 ` [PATCH v2 2/2] OPP: Fix refcount leak bug for opp Liang He
2022-07-19  5:39   ` Viresh Kumar
2022-07-19  5:38 ` [PATCH v2 1/2] OPP: Fix refcount leak bug for opp_table Viresh Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220718133632.937290-1-windhl@126.com \
    --to=windhl@126.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=sboyd@kernel.org \
    --cc=vireshk@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox