mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-10 04:48:04 +09:00
UPSTREAM: vhost: fix error path in vhost_init_used()
We don't want side effects. If something fails, we rollback vq->is_le to
its previous value.
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit e1f33be918)
Bug: 121166534
Test: Ran cuttlefish with android-4.4 + VSOCKETS, VMWARE_VMCI_VSOCKETS
Signed-off-by: Alistair Strachan <astrachan@google.com>
Change-Id: I18c57e5c78aa3e89d267213770f915a5a5c76100
This commit is contained in:
committed by
Alistair Strachan
parent
c7c7d1506c
commit
6ef11fba4c
@@ -1157,6 +1157,8 @@ int vhost_init_used(struct vhost_virtqueue *vq)
|
||||
{
|
||||
__virtio16 last_used_idx;
|
||||
int r;
|
||||
bool is_le = vq->is_le;
|
||||
|
||||
if (!vq->private_data) {
|
||||
vq->is_le = virtio_legacy_is_little_endian();
|
||||
return 0;
|
||||
@@ -1166,15 +1168,20 @@ int vhost_init_used(struct vhost_virtqueue *vq)
|
||||
|
||||
r = vhost_update_used_flags(vq);
|
||||
if (r)
|
||||
return r;
|
||||
goto err;
|
||||
vq->signalled_used_valid = false;
|
||||
if (!access_ok(VERIFY_READ, &vq->used->idx, sizeof vq->used->idx))
|
||||
return -EFAULT;
|
||||
if (!access_ok(VERIFY_READ, &vq->used->idx, sizeof vq->used->idx)) {
|
||||
r = -EFAULT;
|
||||
goto err;
|
||||
}
|
||||
r = __get_user(last_used_idx, &vq->used->idx);
|
||||
if (r)
|
||||
return r;
|
||||
goto err;
|
||||
vq->last_used_idx = vhost16_to_cpu(vq, last_used_idx);
|
||||
return 0;
|
||||
err:
|
||||
vq->is_le = is_le;
|
||||
return r;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(vhost_init_used);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user