Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Asias He and committed by
Michael S. Tsirkin
e7802212 2e26af79

+4 -7
+4 -7
drivers/vhost/scsi.c
··· 896 896 int head, ret; 897 897 u8 target; 898 898 899 + mutex_lock(&vq->mutex); 899 900 /* 900 901 * We can handle the vq only after the endpoint is setup by calling the 901 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 905 if (!vs_tpg) 909 - return; 906 + goto out; 910 907 911 - mutex_lock(&vq->mutex); 912 908 vhost_disable_notify(&vs->dev, vq); 913 909 914 910 for (;;) { ··· 1054 1058 vhost_scsi_free_cmd(cmd); 1055 1059 err_cmd: 1056 1060 vhost_scsi_send_bad_target(vs, vq, head, out); 1061 + out: 1057 1062 mutex_unlock(&vq->mutex); 1058 1063 } 1059 1064