* [bug report] thermal/drivers/cpuidle_cooling: Use device name instead of auto-numbering
@ 2021-03-18 10:20 Dan Carpenter
2021-03-18 10:38 ` Daniel Lezcano
2021-03-19 20:25 ` [PATCH] thermal/drivers/cpuidle_cooling: Fix use after error Daniel Lezcano
0 siblings, 2 replies; 7+ messages in thread
From: Dan Carpenter @ 2021-03-18 10:20 UTC (permalink / raw)
To: daniel.lezcano; +Cc: linux-pm
Hello Daniel Lezcano,
The patch 6fd1b186d900: "thermal/drivers/cpuidle_cooling: Use device
name instead of auto-numbering" from Mar 14, 2021, leads to the
following static checker warning:
drivers/thermal/cpuidle_cooling.c:218 __cpuidle_cooling_register()
warn: 'name' was already freed.
drivers/thermal/cpuidle_cooling.c
200
201 dev = get_cpu_device(cpumask_first(drv->cpumask));
202
203 name = kasprintf(GFP_KERNEL, "idle-%s", dev_name(dev));
204 if (!name) {
205 ret = -ENOMEM;
206 goto out_unregister;
207 }
208
209 cdev = thermal_of_cooling_device_register(np, name, idle_cdev,
210 &cpuidle_cooling_ops);
211 kfree(name);
^^^^^^^^^^^^
212
213 if (IS_ERR(cdev)) {
214 ret = PTR_ERR(cdev);
215 goto out_unregister;
216 }
217
218 pr_debug("%s: Idle injection set with idle duration=%u, latency=%u\n",
219 name, idle_duration_us, latency_us);
^^^^
Used after free
220
221 return 0;
222
223 out_unregister:
224 idle_inject_unregister(ii_dev);
225 out_kfree:
226 kfree(idle_cdev);
227 out:
228 return ret;
229 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [bug report] thermal/drivers/cpuidle_cooling: Use device name instead of auto-numbering
2021-03-18 10:20 [bug report] thermal/drivers/cpuidle_cooling: Use device name instead of auto-numbering Dan Carpenter
@ 2021-03-18 10:38 ` Daniel Lezcano
2021-03-19 20:25 ` [PATCH] thermal/drivers/cpuidle_cooling: Fix use after error Daniel Lezcano
1 sibling, 0 replies; 7+ messages in thread
From: Daniel Lezcano @ 2021-03-18 10:38 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-pm
On 18/03/2021 11:20, Dan Carpenter wrote:
> Hello Daniel Lezcano,
>
> The patch 6fd1b186d900: "thermal/drivers/cpuidle_cooling: Use device
> name instead of auto-numbering" from Mar 14, 2021, leads to the
> following static checker warning:
>
> drivers/thermal/cpuidle_cooling.c:218 __cpuidle_cooling_register()
> warn: 'name' was already freed.
Indeed. I'll fix it.
Thanks for the report
-- Daniel
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] thermal/drivers/cpuidle_cooling: Fix use after error
2021-03-18 10:20 [bug report] thermal/drivers/cpuidle_cooling: Use device name instead of auto-numbering Dan Carpenter
2021-03-18 10:38 ` Daniel Lezcano
@ 2021-03-19 20:25 ` Daniel Lezcano
2021-03-22 3:29 ` Viresh Kumar
2021-04-15 12:04 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
1 sibling, 2 replies; 7+ messages in thread
From: Daniel Lezcano @ 2021-03-19 20:25 UTC (permalink / raw)
To: daniel.lezcano
Cc: Dan Carpenter, Amit Daniel Kachhap, Viresh Kumar, Javi Merino,
Zhang Rui, Amit Kucheria, open list:THERMAL/CPU_COOLING,
open list
When the function successfully finishes it logs an information about
the registration of the cooling device and use its name to build the
message. Unfortunately it was freed right before:
drivers/thermal/cpuidle_cooling.c:218 __cpuidle_cooling_register()
warn: 'name' was already freed.
Fix this by freeing after the message happened.
Fixes: 6fd1b186d900 ("thermal/drivers/cpuidle_cooling: Use device name instead of auto-numbering")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
drivers/thermal/cpuidle_cooling.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/thermal/cpuidle_cooling.c b/drivers/thermal/cpuidle_cooling.c
index f32976163bad..4f41102e8b16 100644
--- a/drivers/thermal/cpuidle_cooling.c
+++ b/drivers/thermal/cpuidle_cooling.c
@@ -208,18 +208,20 @@ static int __cpuidle_cooling_register(struct device_node *np,
cdev = thermal_of_cooling_device_register(np, name, idle_cdev,
&cpuidle_cooling_ops);
- kfree(name);
-
if (IS_ERR(cdev)) {
ret = PTR_ERR(cdev);
- goto out_unregister;
+ goto out_kfree_name;
}
pr_debug("%s: Idle injection set with idle duration=%u, latency=%u\n",
name, idle_duration_us, latency_us);
+ kfree(name);
+
return 0;
+out_kfree_name:
+ kfree(name);
out_unregister:
idle_inject_unregister(ii_dev);
out_kfree:
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] thermal/drivers/cpuidle_cooling: Fix use after error
2021-03-19 20:25 ` [PATCH] thermal/drivers/cpuidle_cooling: Fix use after error Daniel Lezcano
@ 2021-03-22 3:29 ` Viresh Kumar
2021-03-22 8:08 ` Daniel Lezcano
2021-04-15 12:04 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
1 sibling, 1 reply; 7+ messages in thread
From: Viresh Kumar @ 2021-03-22 3:29 UTC (permalink / raw)
To: Daniel Lezcano
Cc: Dan Carpenter, Amit Daniel Kachhap, Javi Merino, Zhang Rui,
Amit Kucheria, open list:THERMAL/CPU_COOLING, open list
On 19-03-21, 21:25, Daniel Lezcano wrote:
> When the function successfully finishes it logs an information about
> the registration of the cooling device and use its name to build the
> message. Unfortunately it was freed right before:
>
> drivers/thermal/cpuidle_cooling.c:218 __cpuidle_cooling_register()
> warn: 'name' was already freed.
>
> Fix this by freeing after the message happened.
>
> Fixes: 6fd1b186d900 ("thermal/drivers/cpuidle_cooling: Use device name instead of auto-numbering")
Why not merge this with the Fixes patch itself since it isn't there in Linus's
tree yet ?
Or is your branch strictly immutable ?
--
viresh
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] thermal/drivers/cpuidle_cooling: Fix use after error
2021-03-22 3:29 ` Viresh Kumar
@ 2021-03-22 8:08 ` Daniel Lezcano
2021-03-22 8:12 ` Viresh Kumar
0 siblings, 1 reply; 7+ messages in thread
From: Daniel Lezcano @ 2021-03-22 8:08 UTC (permalink / raw)
To: Viresh Kumar
Cc: Dan Carpenter, Amit Daniel Kachhap, Javi Merino, Zhang Rui,
Amit Kucheria, open list:THERMAL/CPU_COOLING, open list
On 22/03/2021 04:29, Viresh Kumar wrote:
> On 19-03-21, 21:25, Daniel Lezcano wrote:
>> When the function successfully finishes it logs an information about
>> the registration of the cooling device and use its name to build the
>> message. Unfortunately it was freed right before:
>>
>> drivers/thermal/cpuidle_cooling.c:218 __cpuidle_cooling_register()
>> warn: 'name' was already freed.
>>
>> Fix this by freeing after the message happened.
>>
>> Fixes: 6fd1b186d900 ("thermal/drivers/cpuidle_cooling: Use device name instead of auto-numbering")
>
> Why not merge this with the Fixes patch itself since it isn't there in Linus's
> tree yet ?
>
> Or is your branch strictly immutable ?
Hi Viresh;
The changes follow the path:
testing -> linux-next -> next
The branch next is never rebased. The patch above reached it. This is
notified by the thermal-bot [1].
-- Daniel
[1]
https://lore.kernel.org/linux-pm/20210314111333.16551-3-daniel.lezcano@linaro.org/T/#ma257519efc70ee60faca47dbd458b05de5449bf8
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] thermal/drivers/cpuidle_cooling: Fix use after error
2021-03-22 8:08 ` Daniel Lezcano
@ 2021-03-22 8:12 ` Viresh Kumar
0 siblings, 0 replies; 7+ messages in thread
From: Viresh Kumar @ 2021-03-22 8:12 UTC (permalink / raw)
To: Daniel Lezcano
Cc: Dan Carpenter, Amit Daniel Kachhap, Javi Merino, Zhang Rui,
Amit Kucheria, open list:THERMAL/CPU_COOLING, open list
On 22-03-21, 09:08, Daniel Lezcano wrote:
> On 22/03/2021 04:29, Viresh Kumar wrote:
> > On 19-03-21, 21:25, Daniel Lezcano wrote:
> >> When the function successfully finishes it logs an information about
> >> the registration of the cooling device and use its name to build the
> >> message. Unfortunately it was freed right before:
> >>
> >> drivers/thermal/cpuidle_cooling.c:218 __cpuidle_cooling_register()
> >> warn: 'name' was already freed.
> >>
> >> Fix this by freeing after the message happened.
> >>
> >> Fixes: 6fd1b186d900 ("thermal/drivers/cpuidle_cooling: Use device name instead of auto-numbering")
> >
> > Why not merge this with the Fixes patch itself since it isn't there in Linus's
> > tree yet ?
> >
> > Or is your branch strictly immutable ?
>
> Hi Viresh;
>
> The changes follow the path:
>
> testing -> linux-next -> next
>
> The branch next is never rebased. The patch above reached it. This is
> notified by the thermal-bot [1].
Ahh, I see.
Here you go :)
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
^ permalink raw reply [flat|nested] 7+ messages in thread
* [thermal: thermal/next] thermal/drivers/cpuidle_cooling: Fix use after error
2021-03-19 20:25 ` [PATCH] thermal/drivers/cpuidle_cooling: Fix use after error Daniel Lezcano
2021-03-22 3:29 ` Viresh Kumar
@ 2021-04-15 12:04 ` thermal-bot for Daniel Lezcano
1 sibling, 0 replies; 7+ messages in thread
From: thermal-bot for Daniel Lezcano @ 2021-04-15 12:04 UTC (permalink / raw)
To: linux-pm; +Cc: Dan Carpenter, Daniel Lezcano, Viresh Kumar, rui.zhang, amitk
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 6cc7b38c0ca3187abd07af849ec179b42337bcf6
Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//6cc7b38c0ca3187abd07af849ec179b42337bcf6
Author: Daniel Lezcano <daniel.lezcano@linaro.org>
AuthorDate: Fri, 19 Mar 2021 21:25:22 +01:00
Committer: Daniel Lezcano <daniel.lezcano@linaro.org>
CommitterDate: Thu, 15 Apr 2021 13:21:26 +02:00
thermal/drivers/cpuidle_cooling: Fix use after error
When the function successfully finishes it logs an information about
the registration of the cooling device and use its name to build the
message. Unfortunately it was freed right before:
drivers/thermal/cpuidle_cooling.c:218 __cpuidle_cooling_register()
warn: 'name' was already freed.
Fix this by freeing after the message happened.
Fixes: 6fd1b186d900 ("thermal/drivers/cpuidle_cooling: Use device name instead of auto-numbering")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Link: https://lore.kernel.org/r/20210319202522.891061-1-daniel.lezcano@linaro.org
---
drivers/thermal/cpuidle_cooling.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/thermal/cpuidle_cooling.c b/drivers/thermal/cpuidle_cooling.c
index f329761..4f41102 100644
--- a/drivers/thermal/cpuidle_cooling.c
+++ b/drivers/thermal/cpuidle_cooling.c
@@ -208,18 +208,20 @@ static int __cpuidle_cooling_register(struct device_node *np,
cdev = thermal_of_cooling_device_register(np, name, idle_cdev,
&cpuidle_cooling_ops);
- kfree(name);
-
if (IS_ERR(cdev)) {
ret = PTR_ERR(cdev);
- goto out_unregister;
+ goto out_kfree_name;
}
pr_debug("%s: Idle injection set with idle duration=%u, latency=%u\n",
name, idle_duration_us, latency_us);
+ kfree(name);
+
return 0;
+out_kfree_name:
+ kfree(name);
out_unregister:
idle_inject_unregister(ii_dev);
out_kfree:
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-04-15 12:04 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-18 10:20 [bug report] thermal/drivers/cpuidle_cooling: Use device name instead of auto-numbering Dan Carpenter
2021-03-18 10:38 ` Daniel Lezcano
2021-03-19 20:25 ` [PATCH] thermal/drivers/cpuidle_cooling: Fix use after error Daniel Lezcano
2021-03-22 3:29 ` Viresh Kumar
2021-03-22 8:08 ` Daniel Lezcano
2021-03-22 8:12 ` Viresh Kumar
2021-04-15 12:04 ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.