linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Jacky Bai <ping.bai@nxp.com>
To: "festevam@gmail.com" <festevam@gmail.com>,
	"shawnguo@kernel.org" <shawnguo@kernel.org>,
	"viresh.kumar@linaro.org" <viresh.kumar@linaro.org>,
	"rjw@rjwysocki.net" <rjw@rjwysocki.net>,
	"s.hauer@pengutronix.de" <s.hauer@pengutronix.de>
Cc: "linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	dl-linux-imx <linux-imx@nxp.com>,
	"kernel@pengutronix.de" <kernel@pengutronix.de>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>
Subject: [PATCH v2] cpufreq: imx6q: Fix the resource leak caused by incorrect error return
Date: Sun, 5 May 2019 08:02:48 +0000	[thread overview]
Message-ID: <20190505080736.27970-1-ping.bai@nxp.com> (raw)

Previous goto only handled the node reference, the opp table,
regulator & clk resource also need to be free before error return.

Fixes: ddb64c5db3c (cpufreq: imx6q: fix possible object reference leak).
Signed-off-by: Jacky Bai <ping.bai@nxp.com>
Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/cpufreq/imx6q-cpufreq.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c
index 3e17560b1efe..1d4ecefaabc6 100644
--- a/drivers/cpufreq/imx6q-cpufreq.c
+++ b/drivers/cpufreq/imx6q-cpufreq.c
@@ -383,23 +383,22 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
 		goto put_reg;
 	}
 
+	/* Because we have added the OPPs here, we must free them */
+	free_opp = true;
+
 	if (of_machine_is_compatible("fsl,imx6ul") ||
 	    of_machine_is_compatible("fsl,imx6ull")) {
 		ret = imx6ul_opp_check_speed_grading(cpu_dev);
 		if (ret) {
-			if (ret == -EPROBE_DEFER)
-				goto put_node;
-
-			dev_err(cpu_dev, "failed to read ocotp: %d\n",
-				ret);
-			goto put_node;
+			if (ret != -EPROBE_DEFER)
+				dev_err(cpu_dev, "failed to read ocotp: %d\n",
+					ret);
+			goto out_free_opp;
 		}
 	} else {
 		imx6q_opp_check_speed_grading(cpu_dev);
 	}
 
-	/* Because we have added the OPPs here, we must free them */
-	free_opp = true;
 	num = dev_pm_opp_get_opp_count(cpu_dev);
 	if (num < 0) {
 		ret = num;
-- 
2.21.0

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

             reply	other threads:[~2019-05-05  8:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-05  8:02 Jacky Bai [this message]
2019-05-07  5:53 ` [PATCH v2] cpufreq: imx6q: Fix the resource leak caused by incorrect error return Viresh Kumar
2019-05-07  6:07   ` Uwe Kleine-König
2019-05-07  6:14     ` 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=20190505080736.27970-1-ping.bai@nxp.com \
    --to=ping.bai@nxp.com \
    --cc=festevam@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --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).