2018-05-31 22:22:39

by Suman Anna

[permalink] [raw]
Subject: [PATCH v3 0/2] ti-cpufreq: minor fixes/cleanups

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



2018-05-31 22:22:48

by Suman Anna

[permalink] [raw]
Subject: [PATCH v3 1/2] cpufreq: ti-cpufreq: Fix an incorrect error return value

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 <[email protected]>
Cc: <[email protected]> # v4.14+
Signed-off-by: Suman Anna <[email protected]>
Acked-by: Viresh Kumar <[email protected]>
---
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


2018-05-31 22:23:32

by Suman Anna

[permalink] [raw]
Subject: [PATCH v3 2/2] cpufreq: ti-cpufreq: Use devres managed API in probe()

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 <[email protected]>
Signed-off-by: Suman Anna <[email protected]>
Acked-by: Viresh Kumar <[email protected]>
---
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


2018-06-12 15:01:50

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH v3 0/2] ti-cpufreq: minor fixes/cleanups

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!