mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] dax/bus: clear parent drvdata when releasing a region
@ 2026-10-28  6:50 Avi Weiss
  0 siblings, 0 replies; only message in thread
From: Avi Weiss @ 2026-10-28  6:50 UTC (permalink / raw)
  To: Dan Williams
  Cc: Vishal Verma, Dave Jiang, Alison Schofield, nvdimm, linux-cxl,
	linux-kernel, Avi Weiss

alloc_dax_region() sets parent drvdata before reserving the resource
and registering sysfs attributes. If either operation fails, the
region is freed but drvdata still points to it. A later allocation
on the same parent is rejected by the non-NULL drvdata check.

The devres unregister action also leaves drvdata pointing to the
released region. Clear drvdata on both allocation error and
unregister paths.

Fixes: d7fe1a67f658 ("dax: add region 'id', 'size', and 'align' attributes")
Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
---
 drivers/dax/bus.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
index b809e1a264afa..dceaa395760e7 100644
--- a/drivers/dax/bus.c
+++ b/drivers/dax/bus.c
@@ -627,6 +627,7 @@ static void dax_region_unregister(void *region)
 	sysfs_remove_groups(&dax_region->dev->kobj,
 			dax_region_attribute_groups);
 	release_resource(&dax_region->res);
+	dev_set_drvdata(dax_region->dev, NULL);
 	dax_region_put(dax_region);
 }
 
@@ -685,6 +686,7 @@ struct dax_region *alloc_dax_region(struct device *parent, int region_id,
 err_sysfs:
 	release_resource(&dax_region->res);
 err_res:
+	dev_set_drvdata(parent, NULL);
 	dax_region_put(dax_region);
 	return NULL;
 }

base-commit: d135ab453a7400a34930bdda1ef4bdc8acfac80e
-- 
2.43.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-28  6:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-28  6:50 [PATCH] dax/bus: clear parent drvdata when releasing a region Avi Weiss

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®