linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cpufreq: sti-cpufreq: fix mem leak in sti_cpufreq_set_opp_info()
@ 2020-10-12 14:01 Frank Lee
  2020-10-28  6:08 ` Viresh Kumar
  0 siblings, 1 reply; 2+ messages in thread
From: Frank Lee @ 2020-10-12 14:01 UTC (permalink / raw)
  To: patrice.chotard, rjw, viresh.kumar, tiny.windzz
  Cc: Yangtao Li, linux-kernel, linux-arm-kernel, linux-pm

From: Yangtao Li <tiny.windzz@gmail.com>

Use dev_pm_opp_put_prop_name() to avoid mem leak, which free opp_table.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
Signed-off-by: Yangtao Li <frank@allwinnertech.com>
---
 drivers/cpufreq/sti-cpufreq.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/cpufreq/sti-cpufreq.c b/drivers/cpufreq/sti-cpufreq.c
index a5ad96d29adc..9668a48dad33 100644
--- a/drivers/cpufreq/sti-cpufreq.c
+++ b/drivers/cpufreq/sti-cpufreq.c
@@ -222,7 +222,8 @@ static int sti_cpufreq_set_opp_info(void)
 	opp_table = dev_pm_opp_set_supported_hw(dev, version, VERSION_ELEMENTS);
 	if (IS_ERR(opp_table)) {
 		dev_err(dev, "Failed to set supported hardware\n");
-		return PTR_ERR(opp_table);
+		ret = PTR_ERR(opp_table);
+		goto err_put_prop_name;
 	}
 
 	dev_dbg(dev, "pcode: %d major: %d minor: %d substrate: %d\n",
@@ -231,6 +232,10 @@ static int sti_cpufreq_set_opp_info(void)
 		version[0], version[1], version[2]);
 
 	return 0;
+
+err_put_prop_name:
+	dev_pm_opp_put_prop_name(opp_table);
+	return ret;
 }
 
 static int sti_cpufreq_fetch_syscon_registers(void)
-- 
2.28.0


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

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

* Re: [PATCH] cpufreq: sti-cpufreq: fix mem leak in sti_cpufreq_set_opp_info()
  2020-10-12 14:01 [PATCH] cpufreq: sti-cpufreq: fix mem leak in sti_cpufreq_set_opp_info() Frank Lee
@ 2020-10-28  6:08 ` Viresh Kumar
  0 siblings, 0 replies; 2+ messages in thread
From: Viresh Kumar @ 2020-10-28  6:08 UTC (permalink / raw)
  To: Frank Lee
  Cc: linux-pm, tiny.windzz, rjw, linux-kernel, patrice.chotard,
	linux-arm-kernel

On 12-10-20, 22:01, Frank Lee wrote:
> From: Yangtao Li <tiny.windzz@gmail.com>
> 
> Use dev_pm_opp_put_prop_name() to avoid mem leak, which free opp_table.
> 
> Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
> Signed-off-by: Yangtao Li <frank@allwinnertech.com>
> ---
>  drivers/cpufreq/sti-cpufreq.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/sti-cpufreq.c b/drivers/cpufreq/sti-cpufreq.c
> index a5ad96d29adc..9668a48dad33 100644
> --- a/drivers/cpufreq/sti-cpufreq.c
> +++ b/drivers/cpufreq/sti-cpufreq.c
> @@ -222,7 +222,8 @@ static int sti_cpufreq_set_opp_info(void)
>  	opp_table = dev_pm_opp_set_supported_hw(dev, version, VERSION_ELEMENTS);
>  	if (IS_ERR(opp_table)) {
>  		dev_err(dev, "Failed to set supported hardware\n");
> -		return PTR_ERR(opp_table);
> +		ret = PTR_ERR(opp_table);
> +		goto err_put_prop_name;
>  	}
>  
>  	dev_dbg(dev, "pcode: %d major: %d minor: %d substrate: %d\n",
> @@ -231,6 +232,10 @@ static int sti_cpufreq_set_opp_info(void)
>  		version[0], version[1], version[2]);
>  
>  	return 0;
> +
> +err_put_prop_name:
> +	dev_pm_opp_put_prop_name(opp_table);
> +	return ret;
>  }
>  
>  static int sti_cpufreq_fetch_syscon_registers(void)

Applied. Thanks.

-- 
viresh

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

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

end of thread, other threads:[~2020-10-28  6:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-12 14:01 [PATCH] cpufreq: sti-cpufreq: fix mem leak in sti_cpufreq_set_opp_info() Frank Lee
2020-10-28  6:08 ` Viresh Kumar

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