From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796384980; b=I1mEjzUypGubxhzyl0ENZM7G6eByf5QHumoMhwkwPbrMa2Yo9BsTuK5EQQzBpXhnbCo3 vyzCiL8CDJFz8jEsgU0Xn1V3EU3Y9NEWX3aKAMOaj86CS5SEXuK0JdiwEt5z+ywdY3roQ 8rJenI1ATvCUalRAr46rUxOHG7ExhSWP98gK0+UadVu1bufSSUzD5gP7WjPb+hZEYyjGu 4iX73Dq820joNdCSWiNRcsOaQsZRq6ILnnekeO6hN09tHoQOIrme4vlUqWQD7oKXnNVdo 5ZST11jOIsXyUgrjm5tbpt1kFNRyY+3RvJLH6arQ8QxHy1J1gH4LQbAMf2ryfBZCSmg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384980; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=1/ZmLXndyUiTE9aNOEJK+h5XwHNgya820erjn8MKFhY=; b=VtBUuC7SIVISFDdwLgTlRK9yncotWTg0or9Y0o87nEJHz8Bgj/J2BRcZ4TCsfvPWprgM hrgCfzoX2bM4YDrribGUv2ntKoOzA7PtaQRgiCHKJjN9VbZpsUaU5oUk3EQA/Dn96L4FB loEwD+j/ZIRt6AYFrDIC7gdxdowOpTmX42Syc9ZkTos+e1glkaM1gOFqWxQmcCLjzPy8G /my1aJORT9zXYJGk3cHVXbBiRft+snk6MGXiyTHMNSDX9Zc1W3b/npsb904a8S9ZjB6se Al37abzhzcORZhNqnlf9aCZD27COifRq6RvpWKs1Z5JfGu4Lf1d8q3BGeSe1K8lEnWA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=yUmfUjjg; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59BCC606A330; Fri, 4 Dec 2026 11:49:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=yUmfUjjg Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61E781F00A05; Fri, 4 Dec 2026 11:49:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384979; bh=1/ZmLXndyUiTE9aNOEJK+h5XwHNgya820erjn8MKFhY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=yUmfUjjgaYcuZquWewCRxJYaJKPKQgx8LVTSaFeCqioiNhuZq0AsJA59yRYAO0Q73 wfWUGERpqiL8n37FmC2zs1T0LtkbP1oei8NFoSusqRuoOVNyW/lMmV9NBIwSeohgRb 1QX/+LKsc/GX/NTnuzqAtJ8VvPt1i9x2eCGnzC5Q= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Guixin Liu , Richard Cheng , Li Ming , Dave Jiang , Sasha Levin Subject: [PATCH 6.6 0329/1167] cxl/region: Unregister the pmem region when the bridge is unbound Date: Fri, 4 Dec 2026 18:55:56 +0900 Message-ID: <20261204100710.574674685@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Guixin Liu [ Upstream commit bb26797c08d408ea7e8d3625045f0fe28714a425 ] Removing cxl_acpi unbinds the nvdimm bridge before the regions it serves. A region probe can therefore register its cxl_pmem_region and only then find the bridge unbound, which leaves the new device with nothing to remove it. The orphan outlives the teardown and pins its region and its memdevs, so a later cxl_acpi bind renumbers the root port, ports, endpoints, decoders and the memdev. Unregister the cxl_pmem_region when the bridge is unbound. Found by code inspection. Racing a cxl_region bind against a cxl_acpi unbind leaked a pmem_region device on 12 of 12 attempts, and none with this patch. Fixes: f17b558d6663 ("cxl/pmem: Refactor nvdimm device registration, delete the workqueue") Signed-off-by: Guixin Liu Reviewed-by: Richard Cheng Reviewed-by: Li Ming Reviewed-by: Dave Jiang Link: https://patch.msgid.link/20260831061120.200790-1-kanie@linux.alibaba.com Signed-off-by: Dave Jiang [ sashal: Moved the fix from the split-out pmem region file into region.c and kept the existing device_lock()/device_unlock() calls instead of scoped_guard(). ] Signed-off-by: Sasha Levin --- drivers/cxl/core/region.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 873ee24a34317..f93e5f03d60db 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -2872,11 +2872,13 @@ static int devm_cxl_add_pmem_region(struct cxl_region *cxlr) dev_name(dev)); device_lock(&cxl_nvb->dev); - if (cxl_nvb->dev.driver) + if (cxl_nvb->dev.driver) { rc = devm_add_action_or_reset(&cxl_nvb->dev, cxlr_pmem_unregister, cxlr_pmem); - else + } else { rc = -ENXIO; + cxlr_pmem_unregister(cxlr_pmem); + } device_unlock(&cxl_nvb->dev); if (rc) -- 2.53.0