Commit f4bd9822 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost

Pull minor virtio/vhost fixes from Michael Tsirkin:
 "This fixes two minor bugs: error handling in vhost, and capability
  processing in virtio"

* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
  vhost: fix error path in vhost_init_used()
  virtio-pci: read the right virtio_pci_notify_cap field
parents 52ad1296 e1f33be9
...@@ -1156,6 +1156,8 @@ int vhost_init_used(struct vhost_virtqueue *vq) ...@@ -1156,6 +1156,8 @@ int vhost_init_used(struct vhost_virtqueue *vq)
{ {
__virtio16 last_used_idx; __virtio16 last_used_idx;
int r; int r;
bool is_le = vq->is_le;
if (!vq->private_data) { if (!vq->private_data) {
vq->is_le = virtio_legacy_is_little_endian(); vq->is_le = virtio_legacy_is_little_endian();
return 0; return 0;
...@@ -1165,15 +1167,20 @@ int vhost_init_used(struct vhost_virtqueue *vq) ...@@ -1165,15 +1167,20 @@ int vhost_init_used(struct vhost_virtqueue *vq)
r = vhost_update_used_flags(vq); r = vhost_update_used_flags(vq);
if (r) if (r)
return r; goto err;
vq->signalled_used_valid = false; vq->signalled_used_valid = false;
if (!access_ok(VERIFY_READ, &vq->used->idx, sizeof vq->used->idx)) if (!access_ok(VERIFY_READ, &vq->used->idx, sizeof vq->used->idx)) {
return -EFAULT; r = -EFAULT;
goto err;
}
r = __get_user(last_used_idx, &vq->used->idx); r = __get_user(last_used_idx, &vq->used->idx);
if (r) if (r)
return r; goto err;
vq->last_used_idx = vhost16_to_cpu(vq, last_used_idx); vq->last_used_idx = vhost16_to_cpu(vq, last_used_idx);
return 0; return 0;
err:
vq->is_le = is_le;
return r;
} }
EXPORT_SYMBOL_GPL(vhost_init_used); EXPORT_SYMBOL_GPL(vhost_init_used);
......
...@@ -679,7 +679,7 @@ int virtio_pci_modern_probe(struct virtio_pci_device *vp_dev) ...@@ -679,7 +679,7 @@ int virtio_pci_modern_probe(struct virtio_pci_device *vp_dev)
pci_read_config_dword(pci_dev, pci_read_config_dword(pci_dev,
notify + offsetof(struct virtio_pci_notify_cap, notify + offsetof(struct virtio_pci_notify_cap,
cap.length), cap.offset),
&notify_offset); &notify_offset);
/* We don't know how many VQs we'll map, ahead of the time. /* We don't know how many VQs we'll map, ahead of the time.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment