From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 9452F46A60E; Tue, 21 Jul 2026 19:24:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784661872; cv=none; b=nk3KIvgy9x3TPY3iEHu2rMv7ou0V+KBtwDEcn7iqJ8QckpEc3nHP+2Dtnf+QTusRwNe5XI8QT283NW+L8evEVe44kvxJtYY5/zGV9p+lrnWqrht1qmV0ofFS/1sA7kk6mIvfA0fFYCm0bhPMQNbtGG/us6Jje79rWM/55BfgQYk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784661872; c=relaxed/simple; bh=AGxOSJ59PmK55JWGAgXqpLnTSeDb9FFMBNIPTcL1W1o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=adpkfa8+ruMpT1om+ZQwOYrWPqQ8fNoXs22fzUlTHgT8yweX+RtU/m28vFAxHunJwklSOPWqXP9wJKo7+bTYYYBDio8lxwPzkx0vb6IathRS4xzYIkQwQNB/Nctc5fLxSTgdN1MFZ4Yy1O85KY4BBXGCaGWlehnTKlZq3c5DyiU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=UxtTU3vp; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="UxtTU3vp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0EB161F000E9; Tue, 21 Jul 2026 19:24:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784661871; bh=MDbpjqlO3MZZHjLZj/DjVnbdZ1/2BzUWglGmK8L7fVU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=UxtTU3vpX3eEBmLFocYgS62luWi2MeI2EcXQb85HjH6URpv4m5nGF3xDSBaSPP891 qsyhz+bKW6YONStGuT3Bh1a00Qr8AS2nVuEBv351yIF3XHskffownrR4uqbO+s66v+ hzr/+hNb69+++T2ye1SvETi1W8PHADW+FKvXhZIo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Davidlohr Bueso , Ben Cheatham , Alison Schofield , Jonathan Cameron , Dan Williams , Dave Jiang , Vishal Verma , Andrew Morton , Sasha Levin Subject: [PATCH 6.12 0186/1276] dax/kmem: account for partial discontiguous resource upon removal Date: Tue, 21 Jul 2026 17:10:29 +0200 Message-ID: <20260721152450.254986468@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152446.065700225@linuxfoundation.org> References: <20260721152446.065700225@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Davidlohr Bueso [ Upstream commit 8aa442cfce79e2d69e72fc8e0c0864ac2971149d ] When dev_dax_kmem_probe() partially succeeds (at least one range is mapped) but a subsequent range fails request_mem_region() or add_memory_driver_managed(), the probe silently continues, ultimately returning success, but with the corresponding range resource NULL'ed out. dev_dax_kmem_remove() iterates over all dax_device ranges regardless of if the underlying resource exists. When remove_memory() is called later, it returns 0 because the memory was never added which causes dev_dax_kmem_remove() to incorrectly assume the (nonexistent) resource can be removed and attempts cleanup on a NULL pointer. Fix this by skipping these ranges altogether, noting that these cases are considered success, such that the cleanup is still reached when all actually-added ranges are successfully removed. Link: https://lore.kernel.org/20260223201516.1517657-1-dave@stgolabs.net Fixes: 60e93dc097f7 ("device-dax: add dis-contiguous resource support") Signed-off-by: Davidlohr Bueso Reviewed-by: Ben Cheatham Reviewed-by: Alison Schofield Reviewed-by: Jonathan Cameron Cc: Dan Williams Cc: Dave Jiang Cc: Vishal Verma Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin --- drivers/dax/kmem.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/dax/kmem.c b/drivers/dax/kmem.c index e97d47f42ee2e9..a09bdc17e8f6ec 100644 --- a/drivers/dax/kmem.c +++ b/drivers/dax/kmem.c @@ -220,6 +220,12 @@ static void dev_dax_kmem_remove(struct dev_dax *dev_dax) if (rc) continue; + /* range was never added during probe */ + if (!data->res[i]) { + success++; + continue; + } + rc = remove_memory(range.start, range_len(&range)); if (rc == 0) { remove_resource(data->res[i]); -- 2.53.0