[PATCH v8 1/9] dax/bus: Use dax_region_put() in alloc_dax_region() error path
From: Smita Koralahalli
Date: Sun Mar 22 2026 - 15:55:18 EST
alloc_dax_region() calls kref_init() on the dax_region early in the
function, but the error path for sysfs_create_groups() failure uses
kfree() directly to free the dax_region. This bypasses the kref lifecycle.
Use dax_region_put() instead to handle kref lifecycle correctly.
Suggested-by: Jonathan Cameron <jonathan.cameron@xxxxxxxxxx>
Signed-off-by: Smita Koralahalli <Smita.KoralahalliChannabasappa@xxxxxxx>
---
drivers/dax/bus.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
index c94c09622516..299134c9b294 100644
--- a/drivers/dax/bus.c
+++ b/drivers/dax/bus.c
@@ -668,7 +668,7 @@ struct dax_region *alloc_dax_region(struct device *parent, int region_id,
};
if (sysfs_create_groups(&parent->kobj, dax_region_attribute_groups)) {
- kfree(dax_region);
+ dax_region_put(dax_region);
return NULL;
}
--
2.17.1