diff options
author | Asias He <asias@redhat.com> | 2013-03-14 21:14:05 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2013-03-18 17:34:35 -0400 |
commit | 038e0af4a4fc4db9631aef39ab53e5d991b972ef (patch) | |
tree | 7ca8d79a0b44ee369d629486ced4063bfdaa366d | |
parent | 0fb889b83186e54c0cfa79516599f2267fb553fb (diff) |
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>
-rw-r--r-- | drivers/vhost/tcm_vhost.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/vhost/tcm_vhost.c b/drivers/vhost/tcm_vhost.c index 9951297b2427..79d3aeaff8fa 100644 --- a/drivers/vhost/tcm_vhost.c +++ b/drivers/vhost/tcm_vhost.c | |||
@@ -850,7 +850,7 @@ static int vhost_scsi_clear_endpoint( | |||
850 | for (index = 0; index < vs->dev.nvqs; ++index) { | 850 | for (index = 0; index < vs->dev.nvqs; ++index) { |
851 | if (!vhost_vq_access_ok(&vs->vqs[index])) { | 851 | if (!vhost_vq_access_ok(&vs->vqs[index])) { |
852 | ret = -EFAULT; | 852 | ret = -EFAULT; |
853 | goto err; | 853 | goto err_dev; |
854 | } | 854 | } |
855 | } | 855 | } |
856 | for (i = 0; i < VHOST_SCSI_MAX_TARGET; i++) { | 856 | for (i = 0; i < VHOST_SCSI_MAX_TARGET; i++) { |
@@ -860,10 +860,11 @@ static int vhost_scsi_clear_endpoint( | |||
860 | if (!tv_tpg) | 860 | if (!tv_tpg) |
861 | continue; | 861 | continue; |
862 | 862 | ||
863 | mutex_lock(&tv_tpg->tv_tpg_mutex); | ||
863 | tv_tport = tv_tpg->tport; | 864 | tv_tport = tv_tpg->tport; |
864 | if (!tv_tport) { | 865 | if (!tv_tport) { |
865 | ret = -ENODEV; | 866 | ret = -ENODEV; |
866 | goto err; | 867 | goto err_tpg; |
867 | } | 868 | } |
868 | 869 | ||
869 | if (strcmp(tv_tport->tport_name, t->vhost_wwpn)) { | 870 | if (strcmp(tv_tport->tport_name, t->vhost_wwpn)) { |
@@ -872,16 +873,19 @@ static int vhost_scsi_clear_endpoint( | |||
872 | tv_tport->tport_name, tv_tpg->tport_tpgt, | 873 | tv_tport->tport_name, tv_tpg->tport_tpgt, |
873 | t->vhost_wwpn, t->vhost_tpgt); | 874 | t->vhost_wwpn, t->vhost_tpgt); |
874 | ret = -EINVAL; | 875 | ret = -EINVAL; |
875 | goto err; | 876 | goto err_tpg; |
876 | } | 877 | } |
877 | tv_tpg->tv_tpg_vhost_count--; | 878 | tv_tpg->tv_tpg_vhost_count--; |
878 | vs->vs_tpg[target] = NULL; | 879 | vs->vs_tpg[target] = NULL; |
879 | vs->vs_endpoint = false; | 880 | vs->vs_endpoint = false; |
881 | mutex_unlock(&tv_tpg->tv_tpg_mutex); | ||
880 | } | 882 | } |
881 | mutex_unlock(&vs->dev.mutex); | 883 | mutex_unlock(&vs->dev.mutex); |
882 | return 0; | 884 | return 0; |
883 | 885 | ||
884 | err: | 886 | err_tpg: |
887 | mutex_unlock(&tv_tpg->tv_tpg_mutex); | ||
888 | err_dev: | ||
885 | mutex_unlock(&vs->dev.mutex); | 889 | mutex_unlock(&vs->dev.mutex); |
886 | return ret; | 890 | return ret; |
887 | } | 891 | } |