tcm_vhost: Add missed lock in vhost_scsi_clear_endpoint()
tv_tpg->tv_tpg_vhost_count should be protected by tv_tpg->tv_tpg_mutex. Signed-off-by: Asias He <asias@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
This commit is contained in:
parent
0fb889b831
commit
038e0af4a4
|
@ -850,7 +850,7 @@ static int vhost_scsi_clear_endpoint(
|
||||||
for (index = 0; index < vs->dev.nvqs; ++index) {
|
for (index = 0; index < vs->dev.nvqs; ++index) {
|
||||||
if (!vhost_vq_access_ok(&vs->vqs[index])) {
|
if (!vhost_vq_access_ok(&vs->vqs[index])) {
|
||||||
ret = -EFAULT;
|
ret = -EFAULT;
|
||||||
goto err;
|
goto err_dev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i = 0; i < VHOST_SCSI_MAX_TARGET; i++) {
|
for (i = 0; i < VHOST_SCSI_MAX_TARGET; i++) {
|
||||||
|
@ -860,10 +860,11 @@ static int vhost_scsi_clear_endpoint(
|
||||||
if (!tv_tpg)
|
if (!tv_tpg)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
mutex_lock(&tv_tpg->tv_tpg_mutex);
|
||||||
tv_tport = tv_tpg->tport;
|
tv_tport = tv_tpg->tport;
|
||||||
if (!tv_tport) {
|
if (!tv_tport) {
|
||||||
ret = -ENODEV;
|
ret = -ENODEV;
|
||||||
goto err;
|
goto err_tpg;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(tv_tport->tport_name, t->vhost_wwpn)) {
|
if (strcmp(tv_tport->tport_name, t->vhost_wwpn)) {
|
||||||
|
@ -872,16 +873,19 @@ static int vhost_scsi_clear_endpoint(
|
||||||
tv_tport->tport_name, tv_tpg->tport_tpgt,
|
tv_tport->tport_name, tv_tpg->tport_tpgt,
|
||||||
t->vhost_wwpn, t->vhost_tpgt);
|
t->vhost_wwpn, t->vhost_tpgt);
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto err;
|
goto err_tpg;
|
||||||
}
|
}
|
||||||
tv_tpg->tv_tpg_vhost_count--;
|
tv_tpg->tv_tpg_vhost_count--;
|
||||||
vs->vs_tpg[target] = NULL;
|
vs->vs_tpg[target] = NULL;
|
||||||
vs->vs_endpoint = false;
|
vs->vs_endpoint = false;
|
||||||
|
mutex_unlock(&tv_tpg->tv_tpg_mutex);
|
||||||
}
|
}
|
||||||
mutex_unlock(&vs->dev.mutex);
|
mutex_unlock(&vs->dev.mutex);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err:
|
err_tpg:
|
||||||
|
mutex_unlock(&tv_tpg->tv_tpg_mutex);
|
||||||
|
err_dev:
|
||||||
mutex_unlock(&vs->dev.mutex);
|
mutex_unlock(&vs->dev.mutex);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue