From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-173.mta0.migadu.com (out-173.mta0.migadu.com [91.218.175.173]) (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 1BA063AE1A5 for ; Thu, 28 May 2026 09:38:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779961092; cv=none; b=OiNa5pWg7th44JByR2UMND0QpKurAv8r6lZmrZlVL/IUo1p8MPyQ6FnGfLwvNA9J0YA2Um9QDlRNiLePkKYfRCDt8PPw95U94onLMTimr9fgFZ/NrwrqobXaPFbUZXajBjiGPkQ71ycH10Sq07G+NeM42AhxWFS4TLHsVid5J4M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779961092; c=relaxed/simple; bh=5fdPGmsaekgSXFdnDNIqxNfeLfEf8EE6+pf01BBiDdU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=CHerBWXw+RXnPH/mFNmH1QKQ3OZPriR34ItpzIgPOX6vQsteuTMIciNjsWJ4R2eOnQzQ7hBKaOKO822m9I8x0Ccfhw1+FvzL7IK8kN1zsVYVIdjSvCepRz5Mh9IFgfMBOM22pj8i9lKnwgUZ/bjq5vLYdDVDpMbbJ/8Ia1PnNnM= 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=Rua/h5+p; arc=none smtp.client-ip=91.218.175.173 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="Rua/h5+p" 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=1779961077; 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=168BIu5dc0NAbe1hBH5woqQWWLGcJ7sVc64Of2NFMLA=; b=Rua/h5+pt/9jMZ7YFK9O/0Xvi+MqXZxpiRYslAQjiUFWz+UXNeuZGX6isMAwaSqSBENVuT YFlqRtxCB5wDvNNgTgrlbw9OkDilpT4VdeyLoVi3Ztu49Wt6Czwzw5gnwFRWt1QXVFM46R u/cY2vT0AWG9k2wZlRg+kCP8VpSSrPo= From: Guopeng Zhang To: Waiman Long , Tejun Heo , Johannes Weiner , =?UTF-8?q?Michal=20Koutn=C3=BD?= Cc: Chen Ridong , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Guopeng Zhang Subject: [PATCH] cgroup/cpuset: Free sched domains on rebuild guard failure Date: Thu, 28 May 2026 17:37:42 +0800 Message-ID: <20260528093742.1792456-1-guopeng.zhang@linux.dev> Precedence: bulk X-Mailing-List: cgroups@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT From: Guopeng Zhang generate_sched_domains() returns sched-domain masks and optional attributes that are normally handed to partition_sched_domains(), which takes ownership of them. rebuild_sched_domains_locked() has a WARN guard after generate_sched_domains() and before partition_sched_domains() to avoid passing offline CPUs into the scheduler domain rebuild path. If that guard fires, the function currently returns directly without freeing the generated doms and attr. Free the generated sched-domain masks and attributes before returning from the guard failure path. Signed-off-by: Guopeng Zhang --- kernel/cgroup/cpuset.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 51327333980a..c5fdebc205d8 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1004,8 +1004,11 @@ void rebuild_sched_domains_locked(void) * prevent the panic. */ for (i = 0; doms && i < ndoms; i++) { - if (WARN_ON_ONCE(!cpumask_subset(doms[i], cpu_active_mask))) + if (WARN_ON_ONCE(!cpumask_subset(doms[i], cpu_active_mask))) { + free_sched_domains(doms, ndoms); + kfree(attr); return; + } } /* Have scheduler rebuild the domains */ -- 2.43.0