* [PATCH] sched/topology: Convert kzalloc() to kcalloc() in topology.c
@ 2025-11-24 3:09 Fushuai Wang
0 siblings, 0 replies; only message in thread
From: Fushuai Wang @ 2025-11-24 3:09 UTC (permalink / raw)
To: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
rostedt, bsegall, mgorman, vschneid
Cc: linux-kernel, wangfushuai, Fushuai Wang
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 444bdfdab731..d1e3c6da3570 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -1993,7 +1993,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;
@@ -2002,7 +2002,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;
@@ -2031,7 +2031,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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-11-24 3:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-24 3:09 [PATCH] sched/topology: Convert kzalloc() to kcalloc() in topology.c Fushuai Wang
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®