mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-09 12:17:12 +09:00
UPSTREAM: vhost/vsock: handle vhost_vq_init_access() error
[ Upstream commit0516ffd88f] 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> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commitae36f6a65a) Bug: 121166534 Test: Ran cuttlefish with android-4.4 + vsock adb tunnel Signed-off-by: Cody Schuffelen <schuffelen@google.com> Change-Id: I1e062ae003b92d000967921014a31bfc574632d8
This commit is contained in:
committed by
Alistair Strachan
parent
d8e26f878c
commit
7f320a9370
@@ -376,6 +376,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;
|
||||
|
||||
@@ -386,19 +387,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);
|
||||
@@ -408,8 +410,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;
|
||||
|
||||
Reference in New Issue
Block a user