scst_vdisk: Hold a reference on the associated struct scst_device

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8031 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2019-03-10 04:38:33 +00:00
parent cdfabd20ed
commit 3bcc08ebed

View File

@@ -1308,13 +1308,17 @@ next:
res = scst_pr_set_cluster_mode(dev, dev->cluster_mode,
virt_dev->t10_dev_id);
if (res)
goto out;
percpu_ref_get(&dev->refcnt);
out:
TRACE_EXIT();
return res;
}
/* scst_mutex supposed to be held */
/* Detach a virtual device from a device. scst_mutex is supposed to be held. */
static void vdisk_detach(struct scst_device *dev)
{
struct scst_vdisk_dev *virt_dev = dev->dh_priv;
@@ -1332,6 +1336,8 @@ static void vdisk_detach(struct scst_device *dev)
/* virt_dev will be freed by the caller */
dev->dh_priv = NULL;
virt_dev->dev = NULL;
percpu_ref_put(&dev->refcnt);
TRACE_EXIT();
return;