diff options
author | Asias He <asias@redhat.com> | 2013-05-07 02:54:35 -0400 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2013-07-11 08:37:28 -0400 |
commit | e7802212ea4bbbd5db99181942a19ab36ca4b914 (patch) | |
tree | c532c2ff361c7714595fe6a1ff598a2f79f3657b /drivers/vhost/scsi.c | |
parent | 2e26af79b7e24e9644a6c16ad4dca61501fb4b3f (diff) |
vhost-scsi: Always access vq->private_data under vq mutex
Signed-off-by: Asias He <asias@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'drivers/vhost/scsi.c')
-rw-r--r-- | drivers/vhost/scsi.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index 4264840ef7dc..45365396dbbc 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c | |||
@@ -896,19 +896,15 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq) | |||
896 | int head, ret; | 896 | int head, ret; |
897 | u8 target; | 897 | u8 target; |
898 | 898 | ||
899 | mutex_lock(&vq->mutex); | ||
899 | /* | 900 | /* |
900 | * We can handle the vq only after the endpoint is setup by calling the | 901 | * We can handle the vq only after the endpoint is setup by calling the |
901 | * VHOST_SCSI_SET_ENDPOINT ioctl. | 902 | * VHOST_SCSI_SET_ENDPOINT ioctl. |
902 | * | ||
903 | * TODO: Check that we are running from vhost_worker which acts | ||
904 | * as read-side critical section for vhost kind of RCU. | ||
905 | * See the comments in struct vhost_virtqueue in drivers/vhost/vhost.h | ||
906 | */ | 903 | */ |
907 | vs_tpg = rcu_dereference_check(vq->private_data, 1); | 904 | vs_tpg = vq->private_data; |
908 | if (!vs_tpg) | 905 | if (!vs_tpg) |
909 | return; | 906 | goto out; |
910 | 907 | ||
911 | mutex_lock(&vq->mutex); | ||
912 | vhost_disable_notify(&vs->dev, vq); | 908 | vhost_disable_notify(&vs->dev, vq); |
913 | 909 | ||
914 | for (;;) { | 910 | for (;;) { |
@@ -1058,6 +1054,7 @@ err_free: | |||
1058 | vhost_scsi_free_cmd(cmd); | 1054 | vhost_scsi_free_cmd(cmd); |
1059 | err_cmd: | 1055 | err_cmd: |
1060 | vhost_scsi_send_bad_target(vs, vq, head, out); | 1056 | vhost_scsi_send_bad_target(vs, vq, head, out); |
1057 | out: | ||
1061 | mutex_unlock(&vq->mutex); | 1058 | mutex_unlock(&vq->mutex); |
1062 | } | 1059 | } |
1063 | 1060 | ||