From nobody Fri Oct 2 13:07:30 2026 Received: from mailgw1.hygon.cn (unknown [101.204.27.37]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BF1A3361958 for ; Fri, 31 Jul 2026 08:14:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=101.204.27.37 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785485707; cv=none; b=NQsxraTsCIJZwLDOu2AsIiZ/+Xm7kDZUt+ivpBJtWpCwdUSzl6wtdv5EnHp6FmoWMpJxCslbq3oSkEIcoBJ27JRPeHdgMd7NX1jgGeUsqqTRZiDrCQqktdV0Cd0mcgHWF3hFIrNDwKnI2YUrn6C679Y38coa67aNp/fsEvNh4xQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785485707; c=relaxed/simple; bh=XZ9zFGR9N+b3hrwdnqDRg3zVfcGIosD5Hvn/R1ABWHE=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=TpqjAMhnhB5QFgWMVQLxBoj/DDbnLfEntr4FKFDGQUIaWZgJ3e5oiEcHdxQ8GZn9qNEJifZA48MeZ/qnOSH4FJ+NfmbH19tbIs4BICmDPIMI/Lk6odzaMlVStaR+E4m4JwK2JO2/BTFO1Rv24XJAts10B8hNrFaFICJqgbJis/I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=hygon.cn; spf=pass smtp.mailfrom=hygon.cn; arc=none smtp.client-ip=101.204.27.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=hygon.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hygon.cn Received: from maildlp1.hygon.cn (unknown [127.0.0.1]) by mailgw1.hygon.cn (Postfix) with ESMTP id 4hBJl75fhhzTb9d; Fri, 31 Jul 2026 16:14:43 +0800 (CST) Received: from maildlp1.hygon.cn (unknown [172.23.18.60]) by mailgw1.hygon.cn (Postfix) with ESMTP id 4hBJl52djFzTb9d; Fri, 31 Jul 2026 16:14:41 +0800 (CST) Received: from cncheex04.Hygon.cn (unknown [172.23.18.114]) by maildlp1.hygon.cn (Postfix) with ESMTPS id C5C881555; Fri, 31 Jul 2026 16:14:32 +0800 (CST) Received: from localhost.localdomain (172.19.21.38) by cncheex04.Hygon.cn (172.23.18.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.36; Fri, 31 Jul 2026 16:14:39 +0800 From: Fengyu Wang To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot CC: Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , K Prateek Nayak , Chen Yu , Tim Chen , Shrikanth Hegde , , , , , Subject: [PATCH] sched/topology: Free NUMA masks on topology allocation failure Date: Fri, 31 Jul 2026 16:14:13 +0800 Message-ID: <20260731081413.5505-1-wangfengyu@hygon.cn> X-Mailer: git-send-email 2.47.1.windows.1 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-ClientProxiedBy: cncheex06.Hygon.cn (172.23.18.116) To cncheex04.Hygon.cn (172.23.18.114) Content-Type: text/plain; charset="utf-8" sched_init_numa() publishes sched_domains_numa_masks before it allocates the topology array. When that allocation fails, the early return leaves the masks published while sched_domains_numa_levels is still zero: nothing dereferences them, but nothing can free them either, and the topology they were built for is never installed. Unpublish and free them instead. Fixes: cb83b629bae0 ("sched/numa: Rewrite the CONFIG_NUMA sched domain supp= ort") Signed-off-by: Fengyu Wang --- Tested by hardcoding tl to NULL right after the kzalloc() to force the failure path; the masks are released and the machine boots normally. kernel/sched/topology.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index 622e2e01974c..208fdc52f52d 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -2403,8 +2403,17 @@ void sched_init_numa(int offline_node) =20 tl =3D kzalloc((i + nr_levels + 1) * sizeof(struct sched_domain_topology_level), GFP_KERNEL); - if (!tl) + if (!tl) { + rcu_assign_pointer(sched_domains_numa_masks, NULL); + synchronize_rcu(); + for (i =3D 0; i < nr_levels; i++) { + for_each_node(j) + kfree(masks[i][j]); + kfree(masks[i]); + } + kfree(masks); return; + } =20 /* * Copy the default topology bits.. --=20 2.34.1