[PATCH 1/2] tcmu: delay freeing the device resources until after deletion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Userspace could still be accessing the ring and might
even still have commands it is trying to complete
(if cmd_time_out != 0, so the kernel has dropped the
cmd/ref count and made the device deletable) when a
deletion is executed.

This moves the userspace deletion to the beginning of the
function so we know once it is done userspace is not
accessing the kernel.

Signed-off-by: Mike Christie <mchristi@xxxxxxxxxx>
---
 drivers/target/target_core_user.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index 7d1da43..db129e9 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -1653,6 +1653,8 @@ static void tcmu_destroy_device(struct se_device *dev)
 	bool all_expired = true;
 	int i;
 
+	tcmu_netlink_event(udev, TCMU_CMD_REMOVED_DEVICE, 0, NULL);
+
 	del_timer_sync(&udev->timeout);
 
 	mutex_lock(&root_udev_mutex);
@@ -1680,8 +1682,6 @@ static void tcmu_destroy_device(struct se_device *dev)
 
 	tcmu_blocks_release(udev);
 
-	tcmu_netlink_event(udev, TCMU_CMD_REMOVED_DEVICE, 0, NULL);
-
 	uio_unregister_device(&udev->uio_info);
 
 	/* release ref from configure */
-- 
2.7.2

--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux