From: "Cheatham, Benjamin" <benjamin.cheatham@amd.com>
To: Davidlohr Bueso <dave@stgolabs.net>
Cc: <nvdimm@lists.linux.dev>, <linux-cxl@vger.kernel.org>,
<dan.j.williams@intel.com>, <vishal.l.verma@intel.com>,
<dave.jiang@intel.com>
Subject: Re: [PATCH] dax/kmem: account for partial dis-contiguous resource upon removal
Date: Fri, 20 Feb 2026 13:35:14 -0600 [thread overview]
Message-ID: <88d3975b-e79a-4d0a-8ca9-a67d54cdfe14@amd.com> (raw)
In-Reply-To: <20260210224609.150112-1-dave@stgolabs.net>
On 2/10/2026 4:46 PM, Davidlohr Bueso wrote:
> 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.
I would mention the range resource gets NULL'ed out here. I think it would
make the below easier to follow.
>
> However, dev_dax_kmem_remove() iterates care free on all ranges
> where that remove_memory() returns 0 for "never added memory";
> as walk_memory_blocks() will never see it in the memory_blocks
> xarray. So ultimately passing a nil pointer to remove_resource(),
> which can go boom.
Bit confusing imo. Maybe something like:
"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.
As for the actual fix:
Reviewed-by: Ben Cheatham <benjamin.cheatham@amd.com>
>
> Fix this by skipping these ranges altogether, with the consideration
> that these are considered success, such that the cleanup is still
> reached when all actually-added ranges are successfully removed.
>
> Fixes: 60e93dc097f7 ("device-dax: add dis-contiguous resource support")
> Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
> ---
> drivers/dax/kmem.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/dax/kmem.c b/drivers/dax/kmem.c
> index c036e4d0b610..edd62e68ffb7 100644
> --- a/drivers/dax/kmem.c
> +++ b/drivers/dax/kmem.c
> @@ -227,6 +227,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]);
prev parent reply other threads:[~2026-02-20 19:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-10 22:46 [PATCH] dax/kmem: account for partial dis-contiguous resource upon removal Davidlohr Bueso
2026-02-20 19:35 ` Cheatham, Benjamin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=88d3975b-e79a-4d0a-8ca9-a67d54cdfe14@amd.com \
--to=benjamin.cheatham@amd.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=linux-cxl@vger.kernel.org \
--cc=nvdimm@lists.linux.dev \
--cc=vishal.l.verma@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox