lkml.org 
[lkml]   [2026]   [Mar]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] dax/kmem: account for partial dis-contiguous resource upon removal
ping? Unless any concerns, can this be picked up?

Thanks,
Davidlohr

On Mon, 23 Feb 2026, 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, 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.
>
>Reviewed-by: Ben Cheatham <benjamin.cheatham@amd.com>
>Fixes: 60e93dc097f7 ("device-dax: add dis-contiguous resource support")
>Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
>---
>Changes from v1: reword some of the changelog (Ben)
>
> 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]);
>--
>2.39.5
>

\
 
 \ /
  Last update: 2026-03-11 17:54    [W:0.103 / U:15.965 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and my Meterkast|Read the blog