Skip to contentSkip to conversation

block: rnbd: add .release to rnbd_dev_ktype

PATCH New Salah Triki 1 participant 1 message Apr 28, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 block: rnbd: add .release to rnbd_dev_ktype

After the last kobject_put the .release function of the ktype is called. If this function is not defined the behavior is unpredictable.

Fixes 1eb54f8f5dd8a ("block/rnbd: client: sysfs interface functions")

---
Changes in v2:
- Make the commit message more clearer
- Add a Fixes tag

 drivers/block/rnbd/rnbd-clt-sysfs.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/block/rnbd/rnbd-clt-sysfs.c +8 -0
index 6ea7c12e3a87..144aea1466a4 100644
@@ -475,9 +475,17 @@ void rnbd_clt_remove_dev_symlink(struct rnbd_clt_dev *dev)
 	}
 }
 
+static void rnbd_dev_release(struct kobject *kobj)
+{
+	struct rnbd_clt_dev *dev = container_of(kobj, struct rnbd_clt_dev, kobj);
+
+	kfree(dev);
+}
+
 static const struct kobj_type rnbd_dev_ktype = {
 	.sysfs_ops      = &kobj_sysfs_ops,
 	.default_groups = rnbd_dev_groups,
+	.release	= rnbd_dev_release,
 };
 
 static int rnbd_clt_add_dev_kobj(struct rnbd_clt_dev *dev)
Signature · 1 line
2.43.0