LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v3 0/2] ti-cpufreq: minor fixes/cleanups
@ 2018-05-31 22:21 Suman Anna
  2018-05-31 22:21 ` [PATCH v3 1/2] cpufreq: ti-cpufreq: Fix an incorrect error return value Suman Anna
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Suman Anna @ 2018-05-31 22:21 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Viresh Kumar, Dave Gerlach, Tero Kristo, linux-pm, linux-omap,
	linux-kernel, Suman Anna

Hi Rafael,

This is a repost of the v2 patches Ccing the proper linux-pm list.
There are no code changes, I have picked up Viresh's acks and
also added the stable kernel versions the first patch needs to be
applied to.

regards
Suman

v2: https://marc.info/?l=linux-omap&m=152268780921259&w=2
v1: https://patchwork.kernel.org/patch/10308925/

Suman Anna (2):
  cpufreq: ti-cpufreq: Fix an incorrect error return value
  cpufreq: ti-cpufreq: Use devres managed API in probe()

 drivers/cpufreq/ti-cpufreq.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

-- 
2.17.0

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

* [PATCH v3 1/2] cpufreq: ti-cpufreq: Fix an incorrect error return value
  2018-05-31 22:21 [PATCH v3 0/2] ti-cpufreq: minor fixes/cleanups Suman Anna
@ 2018-05-31 22:21 ` Suman Anna
  2018-05-31 22:21 ` [PATCH v3 2/2] cpufreq: ti-cpufreq: Use devres managed API in probe() Suman Anna
  2018-06-12 14:59 ` [PATCH v3 0/2] ti-cpufreq: minor fixes/cleanups Rafael J. Wysocki
  2 siblings, 0 replies; 4+ messages in thread
From: Suman Anna @ 2018-05-31 22:21 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Viresh Kumar, Dave Gerlach, Tero Kristo, linux-pm, linux-omap,
	linux-kernel, Suman Anna, Zumeng Chen, stable

Commit 05829d9431df ("cpufreq: ti-cpufreq: kfree opp_data when
failure") has fixed a memory leak in the failure path, however
the patch returned a positive value on get_cpu_device() failure
instead of the previous negative value. Fix this incorrect error
return value properly.

Fixes: 05829d9431df ("cpufreq: ti-cpufreq: kfree opp_data when failure")
Cc: Zumeng Chen <zumeng.chen@gmail.com>
Cc: <stable@vger.kernel.org> # v4.14+
Signed-off-by: Suman Anna <s-anna@ti.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/ti-cpufreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpufreq/ti-cpufreq.c b/drivers/cpufreq/ti-cpufreq.c
index 6ba709b6f095..896caba5dfe5 100644
--- a/drivers/cpufreq/ti-cpufreq.c
+++ b/drivers/cpufreq/ti-cpufreq.c
@@ -226,7 +226,7 @@ static int ti_cpufreq_probe(struct platform_device *pdev)
 	opp_data->cpu_dev = get_cpu_device(0);
 	if (!opp_data->cpu_dev) {
 		pr_err("%s: Failed to get device for CPU0\n", __func__);
-		ret = ENODEV;
+		ret = -ENODEV;
 		goto free_opp_data;
 	}
 
-- 
2.17.0

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

* [PATCH v3 2/2] cpufreq: ti-cpufreq: Use devres managed API in probe()
  2018-05-31 22:21 [PATCH v3 0/2] ti-cpufreq: minor fixes/cleanups Suman Anna
  2018-05-31 22:21 ` [PATCH v3 1/2] cpufreq: ti-cpufreq: Fix an incorrect error return value Suman Anna
@ 2018-05-31 22:21 ` Suman Anna
  2018-06-12 14:59 ` [PATCH v3 0/2] ti-cpufreq: minor fixes/cleanups Rafael J. Wysocki
  2 siblings, 0 replies; 4+ messages in thread
From: Suman Anna @ 2018-05-31 22:21 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Viresh Kumar, Dave Gerlach, Tero Kristo, linux-pm, linux-omap,
	linux-kernel, Suman Anna, Zumeng Chen

The ti_cpufreq_probe() function uses regular kzalloc to allocate
the ti_cpufreq_data structure and kfree for freeing this memory
on failures. Simplify this code by using the devres managed
API.

Cc: Zumeng Chen <zumeng.chen@gmail.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/ti-cpufreq.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/cpufreq/ti-cpufreq.c b/drivers/cpufreq/ti-cpufreq.c
index 896caba5dfe5..3f0e2a14895a 100644
--- a/drivers/cpufreq/ti-cpufreq.c
+++ b/drivers/cpufreq/ti-cpufreq.c
@@ -217,7 +217,7 @@ static int ti_cpufreq_probe(struct platform_device *pdev)
 	if (!match)
 		return -ENODEV;
 
-	opp_data = kzalloc(sizeof(*opp_data), GFP_KERNEL);
+	opp_data = devm_kzalloc(&pdev->dev, sizeof(*opp_data), GFP_KERNEL);
 	if (!opp_data)
 		return -ENOMEM;
 
@@ -226,8 +226,7 @@ static int ti_cpufreq_probe(struct platform_device *pdev)
 	opp_data->cpu_dev = get_cpu_device(0);
 	if (!opp_data->cpu_dev) {
 		pr_err("%s: Failed to get device for CPU0\n", __func__);
-		ret = -ENODEV;
-		goto free_opp_data;
+		return -ENODEV;
 	}
 
 	opp_data->opp_node = dev_pm_opp_of_get_opp_desc_node(opp_data->cpu_dev);
@@ -285,8 +284,6 @@ static int ti_cpufreq_probe(struct platform_device *pdev)
 
 fail_put_node:
 	of_node_put(opp_data->opp_node);
-free_opp_data:
-	kfree(opp_data);
 
 	return ret;
 }
-- 
2.17.0

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

* Re: [PATCH v3 0/2] ti-cpufreq: minor fixes/cleanups
  2018-05-31 22:21 [PATCH v3 0/2] ti-cpufreq: minor fixes/cleanups Suman Anna
  2018-05-31 22:21 ` [PATCH v3 1/2] cpufreq: ti-cpufreq: Fix an incorrect error return value Suman Anna
  2018-05-31 22:21 ` [PATCH v3 2/2] cpufreq: ti-cpufreq: Use devres managed API in probe() Suman Anna
@ 2018-06-12 14:59 ` Rafael J. Wysocki
  2 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2018-06-12 14:59 UTC (permalink / raw)
  To: Suman Anna
  Cc: Viresh Kumar, Dave Gerlach, Tero Kristo, linux-pm, linux-omap,
	linux-kernel

On Friday, June 1, 2018 12:21:42 AM CEST Suman Anna wrote:
> Hi Rafael,
> 
> This is a repost of the v2 patches Ccing the proper linux-pm list.
> There are no code changes, I have picked up Viresh's acks and
> also added the stable kernel versions the first patch needs to be
> applied to.
> 
> regards
> Suman
> 
> v2: https://marc.info/?l=linux-omap&m=152268780921259&w=2
> v1: https://patchwork.kernel.org/patch/10308925/
> 
> Suman Anna (2):
>   cpufreq: ti-cpufreq: Fix an incorrect error return value
>   cpufreq: ti-cpufreq: Use devres managed API in probe()
> 
>  drivers/cpufreq/ti-cpufreq.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> 

Applied, thanks!



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

end of thread, other threads:[~2018-06-12 15:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-31 22:21 [PATCH v3 0/2] ti-cpufreq: minor fixes/cleanups Suman Anna
2018-05-31 22:21 ` [PATCH v3 1/2] cpufreq: ti-cpufreq: Fix an incorrect error return value Suman Anna
2018-05-31 22:21 ` [PATCH v3 2/2] cpufreq: ti-cpufreq: Use devres managed API in probe() Suman Anna
2018-06-12 14:59 ` [PATCH v3 0/2] ti-cpufreq: minor fixes/cleanups Rafael J. Wysocki

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