From nobody Fri Dec 19 06:30:58 2025 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 A45311F30C3 for ; Thu, 18 Dec 2025 02:57:32 +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=1766026655; cv=none; b=J8Yp117Ifx4oepsPWoP6sVIs73lBqFJjSfpBzgaOyBwIVxVvKDPJvmEeowcRsAugAoisHlkt5DrmRrBW2SpJZZQO+Bj/LowqicvgJeIa677YRCE6HnNuAFDb5sDRd80ehyow8TwW+xlnBybaSU8+rhicaB3SYWToyxnuc126ohs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766026655; c=relaxed/simple; bh=VsVRS13kyoxp90xs99UCHVeF0Tvxdakbo+C5Ntgjy0o=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=VmG6SBBqLqH2O+2yl+xs9ab4PbO5aHjsYcNq3wAz7HaGyS5Y1XBGVbqr3Q6/MI5uRPxAXtI+WiLM8EYveV1+SczYhMt5oWRWLbgpOMIbTwgNBylXjPyHw+6UA4SFGFCi6LmeE8egPl7+5yll3bPX7/sywT3oNKUqGnO2wdlRkUs= 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=rY1pSTvL; 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="rY1pSTvL" 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=1766026650; 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=7s0H407iSgzjqghQijE859Qx0kDsLlvFnESgQ8MNXwk=; b=rY1pSTvL+4Er02XILkFqprkFhA9IZUacMuW65hTFHxArCHUcUpKNnL32Lr5yg/6Nv0v7Xr sKr4BvsLGeHP6XoJcu/9JOiEh/ffHZl4rtS/yDvvclGNwPB0sxq9Yo61wOddBLVr7pjDLZ xgtbjORYRtfB3z9SfdOH2P/rtsHmMbY= 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 v2] sched/topology: Convert kzalloc() to kcalloc() in topology.c Date: Thu, 18 Dec 2025 10:57:07 +0800 Message-Id: <20251218025707.80581-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. Signed-off-by: Fushuai Wang Reviewed-by: Madadi Vineeth Reddy --- v1->v2: remove useless parenthesis 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..d228abe45c12 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