aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/vhost/vsock.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c
index bbbf588540ed..ce5e63d2c66a 100644
--- a/drivers/vhost/vsock.c
+++ b/drivers/vhost/vsock.c
@@ -373,6 +373,7 @@ static void vhost_vsock_handle_rx_kick(struct vhost_work *work)
373 373
374static int vhost_vsock_start(struct vhost_vsock *vsock) 374static int vhost_vsock_start(struct vhost_vsock *vsock)
375{ 375{
376 struct vhost_virtqueue *vq;
376 size_t i; 377 size_t i;
377 int ret; 378 int ret;
378 379
@@ -383,19 +384,20 @@ static int vhost_vsock_start(struct vhost_vsock *vsock)
383 goto err; 384 goto err;
384 385
385 for (i = 0; i < ARRAY_SIZE(vsock->vqs); i++) { 386 for (i = 0; i < ARRAY_SIZE(vsock->vqs); i++) {
386 struct vhost_virtqueue *vq = &vsock->vqs[i]; 387 vq = &vsock->vqs[i];
387 388
388 mutex_lock(&vq->mutex); 389 mutex_lock(&vq->mutex);
389 390
390 if (!vhost_vq_access_ok(vq)) { 391 if (!vhost_vq_access_ok(vq)) {
391 ret = -EFAULT; 392 ret = -EFAULT;
392 mutex_unlock(&vq->mutex);
393 goto err_vq; 393 goto err_vq;
394 } 394 }
395 395
396 if (!vq->private_data) { 396 if (!vq->private_data) {
397 vq->private_data = vsock; 397 vq->private_data = vsock;
398 vhost_vq_init_access(vq); 398 ret = vhost_vq_init_access(vq);
399 if (ret)
400 goto err_vq;
399 } 401 }
400 402
401 mutex_unlock(&vq->mutex); 403 mutex_unlock(&vq->mutex);
@@ -405,8 +407,11 @@ static int vhost_vsock_start(struct vhost_vsock *vsock)
405 return 0; 407 return 0;
406 408
407err_vq: 409err_vq:
410 vq->private_data = NULL;
411 mutex_unlock(&vq->mutex);
412
408 for (i = 0; i < ARRAY_SIZE(vsock->vqs); i++) { 413 for (i = 0; i < ARRAY_SIZE(vsock->vqs); i++) {
409 struct vhost_virtqueue *vq = &vsock->vqs[i]; 414 vq = &vsock->vqs[i];
410 415
411 mutex_lock(&vq->mutex); 416 mutex_lock(&vq->mutex);
412 vq->private_data = NULL; 417 vq->private_data = NULL;