linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lucas Stach <l.stach@pengutronix.de>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Viresh Kumar <viresh.kumar@linaro.org>
Cc: linux-pm@vger.kernel.org
Subject: [PATCH] cpufreq: dt: fix potential double put of cpu OF node
Date: Fri, 26 Sep 2014 15:33:46 +0200	[thread overview]
Message-ID: <1411738426-18375-1-git-send-email-l.stach@pengutronix.de> (raw)

If cpufreq_generic_init() fails we jump into the resource
cleanup path which contains a of_node_put() call. Another
instance of this has already been called at that time
resulting a double decrement of the refcount.

Fix this by calling of_node_put() only after we are sure
that nothing has gone wrong.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/cpufreq/cpufreq-dt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
index e00265066a75..6bbb8b913446 100644
--- a/drivers/cpufreq/cpufreq-dt.c
+++ b/drivers/cpufreq/cpufreq-dt.c
@@ -259,7 +259,6 @@ static int cpufreq_init(struct cpufreq_policy *policy)
 		else
 			priv->cdev = cdev;
 	}
-	of_node_put(np);
 
 	priv->cpu_dev = cpu_dev;
 	priv->cpu_reg = cpu_reg;
@@ -270,6 +269,8 @@ static int cpufreq_init(struct cpufreq_policy *policy)
 	if (ret)
 		goto out_cooling_unregister;
 
+	of_node_put(np);
+
 	return 0;
 
 out_cooling_unregister:
-- 
2.1.0


             reply	other threads:[~2014-09-26 13:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-26 13:33 Lucas Stach [this message]
2014-09-26 22:14 ` [PATCH] cpufreq: dt: fix potential double put of cpu OF node Rafael J. Wysocki
2014-09-29  8:28   ` Lucas Stach

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=1411738426-18375-1-git-send-email-l.stach@pengutronix.de \
    --to=l.stach@pengutronix.de \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=viresh.kumar@linaro.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;
as well as URLs for NNTP newsgroup(s).