Commit 9260695d authored by Mike Christie's avatar Mike Christie Committed by Nicholas Bellinger

tcmu: fix multiple uio open/close sequences

If the uio device is open and closed multiple times, the
kref count will be off due to tcmu_release getting called
multiple times for each close. This patch integrates
Wenji Tang's patch to add a kref_get on open that now
matches the kref_put done on tcmu_release and adds
a kref_put in tcmu_destroy_device to match the kref_get
done in succesful tcmu_configure_device calls.
Signed-off-by: default avatarMike Christie <mchristi@redhat.com>
Cc: Wenji Tang <tang.wenji@zte.com.cn>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent 531283ff
...@@ -1269,6 +1269,7 @@ static int tcmu_open(struct uio_info *info, struct inode *inode) ...@@ -1269,6 +1269,7 @@ static int tcmu_open(struct uio_info *info, struct inode *inode)
return -EBUSY; return -EBUSY;
udev->inode = inode; udev->inode = inode;
kref_get(&udev->kref);
pr_debug("open\n"); pr_debug("open\n");
...@@ -1300,7 +1301,7 @@ static int tcmu_release(struct uio_info *info, struct inode *inode) ...@@ -1300,7 +1301,7 @@ static int tcmu_release(struct uio_info *info, struct inode *inode)
clear_bit(TCMU_DEV_BIT_OPEN, &udev->flags); clear_bit(TCMU_DEV_BIT_OPEN, &udev->flags);
pr_debug("close\n"); pr_debug("close\n");
/* release ref from configure */ /* release ref from open */
kref_put(&udev->kref, tcmu_dev_kref_release); kref_put(&udev->kref, tcmu_dev_kref_release);
return 0; return 0;
} }
...@@ -1596,6 +1597,9 @@ static void tcmu_destroy_device(struct se_device *dev) ...@@ -1596,6 +1597,9 @@ static void tcmu_destroy_device(struct se_device *dev)
tcmu_netlink_event(udev, TCMU_CMD_REMOVED_DEVICE, 0, NULL); tcmu_netlink_event(udev, TCMU_CMD_REMOVED_DEVICE, 0, NULL);
uio_unregister_device(&udev->uio_info); uio_unregister_device(&udev->uio_info);
/* release ref from configure */
kref_put(&udev->kref, tcmu_dev_kref_release);
} }
enum { enum {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment