From nobody Tue Dec 2 01:03:01 2025 Received: from out-174.mta0.migadu.com (out-174.mta0.migadu.com [91.218.175.174]) (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 D350D2AE99 for ; Mon, 24 Nov 2025 03:10:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763953823; cv=none; b=m/kLhQbi3PZL+Az9zM4APBTwF4iDrdsDnFz+WNWAkOiXDadqelvPXc4i0zricWcSpPoil8TQV/t5EkrC1tyMmARBsvNkX2bj6QPqCQrk5dwA2lwP1Sten7B5AIR3aWhhXpefr19MvNaUTLguXT18DFHZS4Fm8VKsL2wfQSOsuOM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763953823; c=relaxed/simple; bh=Vn8l1kLA0DhslUxTpX6BZi6acP+ooBAJsIAg+StXJkI=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=EQnm+pCTvvh45bDlZKL2EEBQNuYeVohWFgBGe1oYccgTFJEIbSZwLsZ/eBSg13K5PVmDQOtGvnwJH2bnRyAmHd9OxvFZl1fw/acN8bkCm+Tn78xlQVJDTQDSLiKmTp4dybp37nypqqEg7mxOLKVksHNgOmXZ+9XJg00crYABb5c= 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=pvIOYo7B; arc=none smtp.client-ip=91.218.175.174 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="pvIOYo7B" 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=1763953814; 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=WaLuJ7rE+LcbjxeEOCDURlLyFsR0ktssxGftV3DksjY=; b=pvIOYo7BCS6Uw4KqFLTiItw9Pr+QmavIHVWEBnECnE6tKzNwAA79sBrlEF5oSW4I/Jlgv3 ++M8fmk+AYxdHR32Uk+dfAS+AZ808+oxE7/xzkDMTenkjnGcxjNElWllRgB1cEITJsX0iY cFeSAak40GiPwvfvfw/y5riJWepQkg4= 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] sched/topology: Convert kzalloc() to kcalloc() in topology.c Date: Mon, 24 Nov 2025 11:09:29 +0800 Message-Id: <20251124030929.7571-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 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 =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 @@ -2002,7 +2002,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 @@ -2031,7 +2031,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