diff mbox series

[2/2] scsi: target: tcmu: Fix memory leak by using new uio callback

Message ID 20210210194031.7422-3-bostroesser@gmail.com (mailing list archive)
State New, archived
Headers show
Series uio and tcmu: Fix memory leak in tcmu by adding new uio feature | expand

Commit Message

Bodo Stroesser Feb. 10, 2021, 7:40 p.m. UTC
Use new uio_info->late_release callback to fix memory leak.

If userspace daemon still holds uio device open or mmap'ed while
tcmu device is removed from configFS, refcount of the tcmu device
never drops down to 0, because uio does not call
uio_info->release - which is tcmu_release - after tcmu had
executed uio_unregister_device. So tcmu device and its allocated
resources are not freed in this situation.

tcmu now sets uio_info->late_release which is called by uio in
the described situation. That way the memory leak is fixed.

Signed-off-by: Bodo Stroesser <bostroesser@gmail.com>
 drivers/target/target_core_user.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series


diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index 6b171fff007b..bf61705ca92b 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -2092,6 +2092,7 @@  static int tcmu_configure_device(struct se_device *dev)
 	info->mmap = tcmu_mmap;
 	info->open = tcmu_open;
 	info->release = tcmu_release;
+	info->late_release = tcmu_release;
 	ret = uio_register_device(tcmu_root_device, info);
 	if (ret)