From nobody Sun Feb 8 07:08:03 2026 Received: from out-177.mta1.migadu.com (out-177.mta1.migadu.com [95.215.58.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 73847340DA4 for ; Wed, 17 Dec 2025 13:06:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765976781; cv=none; b=RTENSFLWFOOBoF2lDmKK8MxxEJTIKmYAdcjpiHMqB1xnUPfBqV5MHeyAv0pJqiwuYJs37eQfcfvnM34jEICjp4v+1nqyNAw8r0CbaKp/dE9zRTd+YyB1iI2Rux5Gax/uDlDO1/VmHc4icSUQm1SiTEBDQmc6PDxmprWRBJ+hLWQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765976781; c=relaxed/simple; bh=fzpVGaKsdpupwkbfODhWEy+Sl+2L+wSKkkRP9EitO+M=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=DlbFa++361oYqhc/L9jZde3Xiw3EVQhDKIiilWhUUyKU2uZIMTbvjyejhDK5/vbIfoN/Tqic60IR+c7QuDboF8zaMl2UQk8Vz1mDkgrJ51I3EG6ZHYqfJ9IJi85C0k7XFA3moi39QrC/k11hBIIKxLvV+84nASshv3sail1N1h0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=ryVTkCF8; arc=none smtp.client-ip=95.215.58.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="ryVTkCF8" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1765976771; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=eMujQn65hg+tl1GrUU5EdoZqsPwlcWV6qaxu+OoKa3g=; b=ryVTkCF8cGOPKvn7omUAHYv16DzfPj4ZjWF0aotH5Ds7pWvIA5VUSon9ioUouCtBgy/YF8 0WCX11BZ/TwOVkSTcc4ryZHnRrX8FQnYNfZ2YZhDK1l65Vl/rGazgO2G+w9WiLfRqV8dCZ gCnvAr3zrmpvrdIQ3MkR7BFnHW3bvtM= From: Fushuai Wang 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 Subject: [PATCH RESEND] sched/topology: Convert kzalloc() to kcalloc() in topology.c Date: Wed, 17 Dec 2025 21:05:45 +0800 Message-Id: <20251217130545.66489-1-fushuai.wang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" The kzalloc() doesn't check for overflows in size multiplication, so Use kcalloc() instead of it. Signed-off-by: Fushuai Wang --- 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) =20 sched_domains_numa_levels =3D 0; =20 - masks =3D kzalloc(sizeof(void *) * nr_levels, GFP_KERNEL); + masks =3D kcalloc(nr_levels, sizeof(void *), GFP_KERNEL); if (!masks) return; =20 @@ -2064,7 +2064,7 @@ void sched_init_numa(int offline_node) * CPUs of nodes that are that many hops away from us. */ for (i =3D 0; i < nr_levels; i++) { - masks[i] =3D kzalloc(nr_node_ids * sizeof(void *), GFP_KERNEL); + masks[i] =3D kcalloc(nr_node_ids, sizeof(void *), GFP_KERNEL); if (!masks[i]) return; =20 @@ -2096,7 +2096,7 @@ void sched_init_numa(int offline_node) /* Compute default topology size */ for (i =3D 0; sched_domain_topology[i].mask; i++); =20 - tl =3D kzalloc((i + nr_levels + 1) * + tl =3D kcalloc((i + nr_levels + 1), sizeof(struct sched_domain_topology_level), GFP_KERNEL); if (!tl) return; --=20 2.36.1