* [PATCH][next] powercap/drivers/dtpm: Fix size of object being allocated
@ 2021-01-04 12:10 Colin King
2021-01-04 14:23 ` Daniel Lezcano
0 siblings, 1 reply; 3+ messages in thread
From: Colin King @ 2021-01-04 12:10 UTC (permalink / raw)
To: Rafael J . Wysocki, Lukasz Luba, Daniel Lezcano, linux-pm
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
The kzalloc allocation for dtpm_cpu is currently allocating the size
of the pointer and not the size of the structure. Fix this by using
the correct sizeof argument.
Addresses-Coverity: ("Wrong sizeof argument")
Fixes: 0e8f68d7f048 ("powercap/drivers/dtpm: Add CPU energy model based support")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/powercap/dtpm_cpu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/powercap/dtpm_cpu.c b/drivers/powercap/dtpm_cpu.c
index 6933c783c6b4..51c366938acd 100644
--- a/drivers/powercap/dtpm_cpu.c
+++ b/drivers/powercap/dtpm_cpu.c
@@ -200,7 +200,7 @@ static int cpuhp_dtpm_cpu_online(unsigned int cpu)
if (!dtpm)
return -EINVAL;
- dtpm_cpu = kzalloc(sizeof(dtpm_cpu), GFP_KERNEL);
+ dtpm_cpu = kzalloc(sizeof(*dtpm_cpu), GFP_KERNEL);
if (!dtpm_cpu)
goto out_kfree_dtpm;
--
2.29.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH][next] powercap/drivers/dtpm: Fix size of object being allocated
2021-01-04 12:10 [PATCH][next] powercap/drivers/dtpm: Fix size of object being allocated Colin King
@ 2021-01-04 14:23 ` Daniel Lezcano
2021-01-07 17:20 ` Rafael J. Wysocki
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Lezcano @ 2021-01-04 14:23 UTC (permalink / raw)
To: Colin King, Rafael J . Wysocki, Lukasz Luba, linux-pm
Cc: kernel-janitors, linux-kernel
On 04/01/2021 13:10, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The kzalloc allocation for dtpm_cpu is currently allocating the size
> of the pointer and not the size of the structure. Fix this by using
> the correct sizeof argument.
>
> Addresses-Coverity: ("Wrong sizeof argument")
> Fixes: 0e8f68d7f048 ("powercap/drivers/dtpm: Add CPU energy model based support")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Good catch, thanks for fixing this
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
> drivers/powercap/dtpm_cpu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/powercap/dtpm_cpu.c b/drivers/powercap/dtpm_cpu.c
> index 6933c783c6b4..51c366938acd 100644
> --- a/drivers/powercap/dtpm_cpu.c
> +++ b/drivers/powercap/dtpm_cpu.c
> @@ -200,7 +200,7 @@ static int cpuhp_dtpm_cpu_online(unsigned int cpu)
> if (!dtpm)
> return -EINVAL;
>
> - dtpm_cpu = kzalloc(sizeof(dtpm_cpu), GFP_KERNEL);
> + dtpm_cpu = kzalloc(sizeof(*dtpm_cpu), GFP_KERNEL);
> if (!dtpm_cpu)
> goto out_kfree_dtpm;
>
>
--
<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][next] powercap/drivers/dtpm: Fix size of object being allocated
2021-01-04 14:23 ` Daniel Lezcano
@ 2021-01-07 17:20 ` Rafael J. Wysocki
0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2021-01-07 17:20 UTC (permalink / raw)
To: Daniel Lezcano, Colin King
Cc: Rafael J . Wysocki, Lukasz Luba, Linux PM, kernel-janitors,
Linux Kernel Mailing List
On Mon, Jan 4, 2021 at 3:24 PM Daniel Lezcano <daniel.lezcano@linaro.org> wrote:
>
> On 04/01/2021 13:10, Colin King wrote:
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > The kzalloc allocation for dtpm_cpu is currently allocating the size
> > of the pointer and not the size of the structure. Fix this by using
> > the correct sizeof argument.
> >
> > Addresses-Coverity: ("Wrong sizeof argument")
> > Fixes: 0e8f68d7f048 ("powercap/drivers/dtpm: Add CPU energy model based support")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
>
> Good catch, thanks for fixing this
>
> Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Applied as 5.12 material, thanks!
> > ---
> > drivers/powercap/dtpm_cpu.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/powercap/dtpm_cpu.c b/drivers/powercap/dtpm_cpu.c
> > index 6933c783c6b4..51c366938acd 100644
> > --- a/drivers/powercap/dtpm_cpu.c
> > +++ b/drivers/powercap/dtpm_cpu.c
> > @@ -200,7 +200,7 @@ static int cpuhp_dtpm_cpu_online(unsigned int cpu)
> > if (!dtpm)
> > return -EINVAL;
> >
> > - dtpm_cpu = kzalloc(sizeof(dtpm_cpu), GFP_KERNEL);
> > + dtpm_cpu = kzalloc(sizeof(*dtpm_cpu), GFP_KERNEL);
> > if (!dtpm_cpu)
> > goto out_kfree_dtpm;
> >
> >
>
>
> --
> <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
end of thread, other threads:[~2021-01-07 17:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-04 12:10 [PATCH][next] powercap/drivers/dtpm: Fix size of object being allocated Colin King
2021-01-04 14:23 ` Daniel Lezcano
2021-01-07 17:20 ` 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).