linux/drivers/dax
Davidlohr Bueso 8aa442cfce dax/kmem: account for partial discontiguous resource upon removal
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: 60e93dc097 ("device-dax: add dis-contiguous resource support")
Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
Reviewed-by: Ben Cheatham <benjamin.cheatham@amd.com>
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
History 2026-05-28 21:04:53 -07:00
..
hmem dax/hmem: Parent dax_hmem devices 2026-04-01 08:12:18 -07:00
bus.c dax changes for 7.1 2026-04-21 14:12:01 -07:00
bus.h dax changes for 7.1 2026-04-21 14:12:01 -07:00
cxl.c dax/hmem, cxl: Defer and resolve Soft Reserved ownership 2026-03-27 10:25:47 -07:00
dax-private.h dax: Add dax_operations for use by fs-dax on fsdev dax 2026-03-30 08:20:48 -05:00
device.c dax changes for 7.1 2026-04-21 14:12:01 -07:00
fsdev.c dax/fsdev: fix uninitialized kaddr in fsdev_dax_zero_page_range() 2026-04-13 14:15:15 -05:00
Kconfig dax changes for 7.1 2026-04-21 14:12:01 -07:00
kmem.c dax/kmem: account for partial discontiguous resource upon removal 2026-05-28 21:04:53 -07:00
Makefile dax changes for 7.1 2026-04-21 14:12:01 -07:00
pmem.c mm: remove callers of pfn_t functionality 2025-07-09 22:42:19 -07:00
super.c dax: export dax_dev_get() 2026-03-30 08:20:48 -05:00