[PATCH] sched/topology: convert NUMA distance masks allocation to kcalloc()

From: William Theesfeld

Date: Fri Jun 05 2026 - 14:24:31 EST


sched_init_numa() builds the per-level NUMA distance masks via an
open-coded kzalloc(nr_node_ids * sizeof(void *), ...). Switch to
kcalloc(), which carries the same zero-on-allocation semantics and
adds the standard size_mul overflow check on the multiplication.

nr_node_ids is bounded by MAX_NUMNODES at compile time, so the
overflow check folds away in practice; the conversion is for
consistency with the kernel-wide pattern and to keep kernel/sched/
free of the open-coded form.

No functional change.

Signed-off-by: William Theesfeld <william@xxxxxxxxxxxxx>
---
kernel/sched/topology.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 5847b83d9..bb900ae22 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -2083,7 +2083,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;

--
2.54.0