diff options
author | Stefan Hajnoczi <stefanha@redhat.com> | 2017-01-19 10:43:53 +0000 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2017-01-25 00:33:10 +0200 |
commit | 0516ffd88fa0d006ee80389ce14a9ca5ae45e845 (patch) | |
tree | 8475350acecd5050469ea13e3c8602d98ec8c6e9 /drivers/vhost | |
parent | 7a308bb3016f57e5be11a677d15b821536419d36 (diff) | |
download | linux-stable-0516ffd88fa0d006ee80389ce14a9ca5ae45e845.tar.gz linux-stable-0516ffd88fa0d006ee80389ce14a9ca5ae45e845.tar.bz2 linux-stable-0516ffd88fa0d006ee80389ce14a9ca5ae45e845.zip |
vhost/vsock: handle vhost_vq_init_access() error
Propagate the error when vhost_vq_init_access() fails and set
vq->private_data to NULL.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'drivers/vhost')
-rw-r--r-- | drivers/vhost/vsock.c | 13 |
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) static int vhost_vsock_start(struct vhost_vsock *vsock) { + struct vhost_virtqueue *vq; size_t i; int ret; @@ -383,19 +384,20 @@ static int vhost_vsock_start(struct vhost_vsock *vsock) goto err; for (i = 0; i < ARRAY_SIZE(vsock->vqs); i++) { - struct vhost_virtqueue *vq = &vsock->vqs[i]; + vq = &vsock->vqs[i]; mutex_lock(&vq->mutex); if (!vhost_vq_access_ok(vq)) { ret = -EFAULT; - mutex_unlock(&vq->mutex); goto err_vq; } if (!vq->private_data) { vq->private_data = vsock; - vhost_vq_init_access(vq); + ret = vhost_vq_init_access(vq); + if (ret) + goto err_vq; } mutex_unlock(&vq->mutex); @@ -405,8 +407,11 @@ static int vhost_vsock_start(struct vhost_vsock *vsock) return 0; err_vq: + vq->private_data = NULL; + mutex_unlock(&vq->mutex); + for (i = 0; i < ARRAY_SIZE(vsock->vqs); i++) { - struct vhost_virtqueue *vq = &vsock->vqs[i]; + vq = &vsock->vqs[i]; mutex_lock(&vq->mutex); vq->private_data = NULL; |