* [PATCH] thermal: thermal_of: fix error return code of thermal_of_populate_bind_params()
@ 2021-03-06 14:11 Jia-Ju Bai
2021-03-10 12:02 ` Daniel Lezcano
0 siblings, 1 reply; 3+ messages in thread
From: Jia-Ju Bai @ 2021-03-06 14:11 UTC (permalink / raw)
To: rui.zhang, daniel.lezcano, amitk; +Cc: linux-pm, linux-kernel, Jia-Ju Bai
When kcalloc() fails and __tcbp is NULL, no error return code of
thermal_of_populate_bind_params() is assigned.
To fix this bug, ret is assigned with -ENOMEM in this case.
Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
drivers/thermal/thermal_of.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
index 69ef12f852b7..e8c9041482e9 100644
--- a/drivers/thermal/thermal_of.c
+++ b/drivers/thermal/thermal_of.c
@@ -710,8 +710,10 @@ static int thermal_of_populate_bind_params(struct device_node *np,
}
__tcbp = kcalloc(count, sizeof(*__tcbp), GFP_KERNEL);
- if (!__tcbp)
+ if (!__tcbp) {
+ ret = -ENOMEM;
goto end;
+ }
for (i = 0; i < count; i++) {
ret = of_parse_phandle_with_args(np, "cooling-device",
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] thermal: thermal_of: fix error return code of thermal_of_populate_bind_params()
2021-03-06 14:11 [PATCH] thermal: thermal_of: fix error return code of thermal_of_populate_bind_params() Jia-Ju Bai
@ 2021-03-10 12:02 ` Daniel Lezcano
2021-03-10 12:09 ` Jia-Ju Bai
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Lezcano @ 2021-03-10 12:02 UTC (permalink / raw)
To: Jia-Ju Bai, rui.zhang, amitk; +Cc: linux-pm, linux-kernel
On 06/03/2021 15:11, Jia-Ju Bai wrote:
> When kcalloc() fails and __tcbp is NULL, no error return code of
> thermal_of_populate_bind_params() is assigned.
> To fix this bug, ret is assigned with -ENOMEM in this case.
>
> Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
> ---
> drivers/thermal/thermal_of.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
> index 69ef12f852b7..e8c9041482e9 100644
> --- a/drivers/thermal/thermal_of.c
> +++ b/drivers/thermal/thermal_of.c
> @@ -710,8 +710,10 @@ static int thermal_of_populate_bind_params(struct device_node *np,
> }
>
> __tcbp = kcalloc(count, sizeof(*__tcbp), GFP_KERNEL);
> - if (!__tcbp)
> + if (!__tcbp) {
> + ret = -ENOMEM;
> goto end;
> + }
Thank you for your patch.
Seems like the same happens a few lines before:
count = of_count_phandle_with_args(np, "cooling-device",
"#cooling-cells");
if (!count) {
pr_err("Add a cooling_device property with at least one
device\n");
goto end;
}
Mind to send a patch fixing both ?
Thanks
-- 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] 3+ messages in thread
* Re: [PATCH] thermal: thermal_of: fix error return code of thermal_of_populate_bind_params()
2021-03-10 12:02 ` Daniel Lezcano
@ 2021-03-10 12:09 ` Jia-Ju Bai
0 siblings, 0 replies; 3+ messages in thread
From: Jia-Ju Bai @ 2021-03-10 12:09 UTC (permalink / raw)
To: Daniel Lezcano, rui.zhang, amitk; +Cc: linux-pm, linux-kernel
On 2021/3/10 20:02, Daniel Lezcano wrote:
> On 06/03/2021 15:11, Jia-Ju Bai wrote:
>> When kcalloc() fails and __tcbp is NULL, no error return code of
>> thermal_of_populate_bind_params() is assigned.
>> To fix this bug, ret is assigned with -ENOMEM in this case.
>>
>> Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
>> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
>> ---
>> drivers/thermal/thermal_of.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
>> index 69ef12f852b7..e8c9041482e9 100644
>> --- a/drivers/thermal/thermal_of.c
>> +++ b/drivers/thermal/thermal_of.c
>> @@ -710,8 +710,10 @@ static int thermal_of_populate_bind_params(struct device_node *np,
>> }
>>
>> __tcbp = kcalloc(count, sizeof(*__tcbp), GFP_KERNEL);
>> - if (!__tcbp)
>> + if (!__tcbp) {
>> + ret = -ENOMEM;
>> goto end;
>> + }
> Thank you for your patch.
>
> Seems like the same happens a few lines before:
>
> count = of_count_phandle_with_args(np, "cooling-device",
> "#cooling-cells");
> if (!count) {
> pr_err("Add a cooling_device property with at least one
> device\n");
> goto end;
> }
>
> Mind to send a patch fixing both ?
>
Thanks for the reply and advice.
I will send a new version of the patch to fix them both.
Best wishes,
Jia-Ju Bai
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-10 12:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-06 14:11 [PATCH] thermal: thermal_of: fix error return code of thermal_of_populate_bind_params() Jia-Ju Bai
2021-03-10 12:02 ` Daniel Lezcano
2021-03-10 12:09 ` Jia-Ju Bai
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).