From: Fushuai Wang <fushuai.wang@linux.dev>
To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
vschneid@redhat.com
Cc: linux-kernel@vger.kernel.org, wangfushuai@baidu.com,
Fushuai Wang <fushuai.wang@linux.dev>
Subject: [PATCH RESEND] sched/topology: Convert kzalloc() to kcalloc() in topology.c
Date: Wed, 17 Dec 2025 21:05:45 +0800 [thread overview]
Message-ID: <20251217130545.66489-1-fushuai.wang@linux.dev> (raw)
The kzalloc() doesn't check for overflows in size multiplication,
so Use kcalloc() instead of it.
Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
---
kernel/sched/topology.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index cf643a5ddedd..f638892b9b96 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -2055,7 +2055,7 @@ void sched_init_numa(int offline_node)
sched_domains_numa_levels = 0;
- masks = kzalloc(sizeof(void *) * nr_levels, GFP_KERNEL);
+ masks = kcalloc(nr_levels, sizeof(void *), GFP_KERNEL);
if (!masks)
return;
@@ -2064,7 +2064,7 @@ void sched_init_numa(int offline_node)
* CPUs of nodes that are that many hops away from us.
*/
for (i = 0; i < nr_levels; i++) {
- masks[i] = kzalloc(nr_node_ids * sizeof(void *), GFP_KERNEL);
+ masks[i] = kcalloc(nr_node_ids, sizeof(void *), GFP_KERNEL);
if (!masks[i])
return;
@@ -2096,7 +2096,7 @@ void sched_init_numa(int offline_node)
/* Compute default topology size */
for (i = 0; sched_domain_topology[i].mask; i++);
- tl = kzalloc((i + nr_levels + 1) *
+ tl = kcalloc((i + nr_levels + 1),
sizeof(struct sched_domain_topology_level), GFP_KERNEL);
if (!tl)
return;
--
2.36.1
next reply other threads:[~2025-12-17 13:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-17 13:05 Fushuai Wang [this message]
2025-12-17 16:24 ` [PATCH RESEND] sched/topology: Convert kzalloc() to kcalloc() in topology.c Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251217130545.66489-1-fushuai.wang@linux.dev \
--to=fushuai.wang@linux.dev \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=wangfushuai@baidu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox