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 C05CD44AB9B; Tue, 21 Jul 2026 21:21:32 +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=1784668893; cv=none; b=YCtSk721b7ZuiFx/l08mjkoHduJpdZ2SZ28lv1a6wp7mOntyejh4KV2qBUX6r8niNu7lt25j3n/JP+c2WNIAAGFwiLRRot/F2sk2DfS3J9C+5rDiw4ziT4WjCQn7RUvNG8iTxHAdHpT1so8xPmGIx3MOhjDwHQdfTKK8Kstg7BA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784668893; c=relaxed/simple; bh=ZTeHg8dog1fMRX0rUKIspj2UxQbX0+p+Ms2Yjq5bBQs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iK71ipcCxsIGsiOg596h9bJy+xvRB5YwKP+OJ2B0y5hrBx1QgyvOZIa/KJXNH2tMjt/rN3FYsGXhmlZ6WhBLlmF8YuCL+zDTmBRx3+1cf7CZoUoGpyrX6ROPHD5ai1TPIq5YcZxf39ANQhwNqn9gxgYIvbDZeMfeyOf+IoJyRpI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=UeN0Cx8Z; 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="UeN0Cx8Z" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3937D1F00A3A; Tue, 21 Jul 2026 21:21:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784668892; bh=wD+1Htg0odvWg+yB/N3qVI/gNOXJeG20zTQ7EjDdBrM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=UeN0Cx8ZIXs3i6+kc6ldWs4tkp0R6k0jw+fkVxnWVkp1CXcb838D3y6lVzFWp9r4g t7OUhaKRstBGEJyYf8lUTPKmT8qlkOHgdgxXL9OpeUZYhc/iKkBERpndsTG6GtCCq8 htsS+f0Xpq8Oohp/s9Hsqk8CIIjXejdTLYFRszq0= 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.1 0349/1067] dax/kmem: account for partial discontiguous resource upon removal Date: Tue, 21 Jul 2026 17:15:50 +0200 Message-ID: <20260721152432.407070770@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152424.521567757@linuxfoundation.org> References: <20260721152424.521567757@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.1-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 1a33616ceb06ee..0d824ba1f4cab2 100644 --- a/drivers/dax/kmem.c +++ b/drivers/dax/kmem.c @@ -193,6 +193,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