Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH] cpufreq: imx6q: Fix the resource leak caused by incorrect error return
@ 2019-05-05  4:34 Jacky Bai
  2019-05-05  4:34 ` Jacky Bai
  2019-05-05  7:30 ` Aisheng Dong
  0 siblings, 2 replies; 4+ messages in thread
From: Jacky Bai @ 2019-05-05  4:34 UTC (permalink / raw)
  To: festevam@gmail.com, shawnguo@kernel.org, viresh.kumar@linaro.org,
	rjw@rjwysocki.net, s.hauer@pengutronix.de
  Cc: linux-arm-kernel@lists.infradead.org, dl-linux-imx,
	kernel@pengutronix.de, linux-pm@vger.kernel.org

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

Signed-off-by: Jacky Bai <ping.bai@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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] cpufreq: imx6q: Fix the resource leak caused by incorrect error return
  2019-05-05  4:34 [PATCH] cpufreq: imx6q: Fix the resource leak caused by incorrect error return Jacky Bai
@ 2019-05-05  4:34 ` Jacky Bai
  2019-05-05  7:30 ` Aisheng Dong
  1 sibling, 0 replies; 4+ messages in thread
From: Jacky Bai @ 2019-05-05  4:34 UTC (permalink / raw)
  To: festevam@gmail.com, shawnguo@kernel.org, viresh.kumar@linaro.org,
	rjw@rjwysocki.net, s.hauer@pengutronix.de
  Cc: kernel@pengutronix.de, dl-linux-imx,
	linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org

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

Signed-off-by: Jacky Bai <ping.bai@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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [PATCH] cpufreq: imx6q: Fix the resource leak caused by incorrect error return
  2019-05-05  4:34 [PATCH] cpufreq: imx6q: Fix the resource leak caused by incorrect error return Jacky Bai
  2019-05-05  4:34 ` Jacky Bai
@ 2019-05-05  7:30 ` Aisheng Dong
  2019-05-05  7:30   ` Aisheng Dong
  1 sibling, 1 reply; 4+ messages in thread
From: Aisheng Dong @ 2019-05-05  7:30 UTC (permalink / raw)
  To: Jacky Bai, festevam@gmail.com, shawnguo@kernel.org,
	viresh.kumar@linaro.org, rjw@rjwysocki.net,
	s.hauer@pengutronix.de
  Cc: linux-arm-kernel@lists.infradead.org, dl-linux-imx,
	kernel@pengutronix.de, linux-pm@vger.kernel.org

> From: Jacky Bai
> Sent: Sunday, May 5, 2019 12:35 PM
> 
> Previous goto only handled the node reference, the opp table, regulator & clk
> resource also need to be free before error return.
> 
> Signed-off-by: Jacky Bai <ping.bai@nxp.com>

Better to have a 'Fixes:' tag.
Otherwise:
Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com>

Regards
Dong Aisheng

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] cpufreq: imx6q: Fix the resource leak caused by incorrect error return
  2019-05-05  7:30 ` Aisheng Dong
@ 2019-05-05  7:30   ` Aisheng Dong
  0 siblings, 0 replies; 4+ messages in thread
From: Aisheng Dong @ 2019-05-05  7:30 UTC (permalink / raw)
  To: Jacky Bai, festevam@gmail.com, shawnguo@kernel.org,
	viresh.kumar@linaro.org, rjw@rjwysocki.net,
	s.hauer@pengutronix.de
  Cc: kernel@pengutronix.de, dl-linux-imx,
	linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org

> From: Jacky Bai
> Sent: Sunday, May 5, 2019 12:35 PM
> 
> Previous goto only handled the node reference, the opp table, regulator & clk
> resource also need to be free before error return.
> 
> Signed-off-by: Jacky Bai <ping.bai@nxp.com>

Better to have a 'Fixes:' tag.
Otherwise:
Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com>

Regards
Dong Aisheng

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-05-05  7:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-05  4:34 [PATCH] cpufreq: imx6q: Fix the resource leak caused by incorrect error return Jacky Bai
2019-05-05  4:34 ` Jacky Bai
2019-05-05  7:30 ` Aisheng Dong
2019-05-05  7:30   ` Aisheng Dong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox