* [PATCH] cpufreq: sparc: change kzalloc to kcalloc
@ 2024-12-23 14:41 Ethan Carter Edwards
2024-12-24 4:19 ` Viresh Kumar
0 siblings, 1 reply; 2+ messages in thread
From: Ethan Carter Edwards @ 2024-12-23 14:41 UTC (permalink / raw)
To: rafael; +Cc: viresh.kumar, linux-pm, linux-kernel
Refactor to use kcalloc instead of kzalloc when multiplying
allocation size by count. This refactor prevents unintentional
memory overflows. Discovered by checkpatch.pl.
Signed-off-by: Ethan Carter Edwards <ethan@ethancedwards.com>
---
drivers/cpufreq/sparc-us2e-cpufreq.c | 2 +-
drivers/cpufreq/sparc-us3-cpufreq.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/cpufreq/sparc-us2e-cpufreq.c b/drivers/cpufreq/sparc-us2e-cpufreq.c
index 8a0cd5312a59..15899dd77c08 100644
--- a/drivers/cpufreq/sparc-us2e-cpufreq.c
+++ b/drivers/cpufreq/sparc-us2e-cpufreq.c
@@ -323,7 +323,7 @@ static int __init us2e_freq_init(void)
impl = ((ver >> 32) & 0xffff);
if (manuf == 0x17 && impl == 0x13) {
- us2e_freq_table = kzalloc(NR_CPUS * sizeof(*us2e_freq_table),
+ us2e_freq_table = kcalloc(NR_CPUS, sizeof(*us2e_freq_table),
GFP_KERNEL);
if (!us2e_freq_table)
return -ENOMEM;
diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
index b50f9d13e6d2..de50a2f3b124 100644
--- a/drivers/cpufreq/sparc-us3-cpufreq.c
+++ b/drivers/cpufreq/sparc-us3-cpufreq.c
@@ -171,7 +171,7 @@ static int __init us3_freq_init(void)
impl == CHEETAH_PLUS_IMPL ||
impl == JAGUAR_IMPL ||
impl == PANTHER_IMPL)) {
- us3_freq_table = kzalloc(NR_CPUS * sizeof(*us3_freq_table),
+ us3_freq_table = kcalloc(NR_CPUS, sizeof(*us3_freq_table),
GFP_KERNEL);
if (!us3_freq_table)
return -ENOMEM;
--
2.47.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] cpufreq: sparc: change kzalloc to kcalloc
2024-12-23 14:41 [PATCH] cpufreq: sparc: change kzalloc to kcalloc Ethan Carter Edwards
@ 2024-12-24 4:19 ` Viresh Kumar
0 siblings, 0 replies; 2+ messages in thread
From: Viresh Kumar @ 2024-12-24 4:19 UTC (permalink / raw)
To: Ethan Carter Edwards; +Cc: rafael, linux-pm, linux-kernel
On 23-12-24, 14:41, Ethan Carter Edwards wrote:
> Refactor to use kcalloc instead of kzalloc when multiplying
> allocation size by count. This refactor prevents unintentional
> memory overflows. Discovered by checkpatch.pl.
>
> Signed-off-by: Ethan Carter Edwards <ethan@ethancedwards.com>
> ---
> drivers/cpufreq/sparc-us2e-cpufreq.c | 2 +-
> drivers/cpufreq/sparc-us3-cpufreq.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cpufreq/sparc-us2e-cpufreq.c b/drivers/cpufreq/sparc-us2e-cpufreq.c
> index 8a0cd5312a59..15899dd77c08 100644
> --- a/drivers/cpufreq/sparc-us2e-cpufreq.c
> +++ b/drivers/cpufreq/sparc-us2e-cpufreq.c
> @@ -323,7 +323,7 @@ static int __init us2e_freq_init(void)
> impl = ((ver >> 32) & 0xffff);
>
> if (manuf == 0x17 && impl == 0x13) {
> - us2e_freq_table = kzalloc(NR_CPUS * sizeof(*us2e_freq_table),
> + us2e_freq_table = kcalloc(NR_CPUS, sizeof(*us2e_freq_table),
> GFP_KERNEL);
> if (!us2e_freq_table)
> return -ENOMEM;
> diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
> index b50f9d13e6d2..de50a2f3b124 100644
> --- a/drivers/cpufreq/sparc-us3-cpufreq.c
> +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
> @@ -171,7 +171,7 @@ static int __init us3_freq_init(void)
> impl == CHEETAH_PLUS_IMPL ||
> impl == JAGUAR_IMPL ||
> impl == PANTHER_IMPL)) {
> - us3_freq_table = kzalloc(NR_CPUS * sizeof(*us3_freq_table),
> + us3_freq_table = kcalloc(NR_CPUS, sizeof(*us3_freq_table),
> GFP_KERNEL);
> if (!us3_freq_table)
> return -ENOMEM;
Applied. Thanks.
Though I failed to apply it directly using git/b4 for some reason, had
to manually make the updates and commit.
--
viresh
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-12-24 4:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-23 14:41 [PATCH] cpufreq: sparc: change kzalloc to kcalloc Ethan Carter Edwards
2024-12-24 4:19 ` Viresh Kumar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®