Skip to content

Commit

Permalink
vhost-scsi: Always access vq->private_data under vq mutex
Browse files Browse the repository at this point in the history
Signed-off-by: Asias He <asias@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
Asias He authored and Michael S. Tsirkin committed Jul 11, 2013
1 parent 2e26af7 commit e780221
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions drivers/vhost/scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -896,19 +896,15 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
int head, ret;
u8 target;

mutex_lock(&vq->mutex);
/*
* We can handle the vq only after the endpoint is setup by calling the
* VHOST_SCSI_SET_ENDPOINT ioctl.
*
* TODO: Check that we are running from vhost_worker which acts
* as read-side critical section for vhost kind of RCU.
* See the comments in struct vhost_virtqueue in drivers/vhost/vhost.h
*/
vs_tpg = rcu_dereference_check(vq->private_data, 1);
vs_tpg = vq->private_data;
if (!vs_tpg)
return;
goto out;

mutex_lock(&vq->mutex);
vhost_disable_notify(&vs->dev, vq);

for (;;) {
Expand Down Expand Up @@ -1058,6 +1054,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
vhost_scsi_free_cmd(cmd);
err_cmd:
vhost_scsi_send_bad_target(vs, vq, head, out);
out:
mutex_unlock(&vq->mutex);
}

Expand Down

0 comments on commit e780221

Please sign in to comment.