Skip to content

Commit f4bd982

Browse files
committed
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
2 parents 52ad129 + e1f33be commit f4bd982

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

drivers/vhost/vhost.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,8 @@ int vhost_init_used(struct vhost_virtqueue *vq)
11561156
{
11571157
__virtio16 last_used_idx;
11581158
int r;
1159+
bool is_le = vq->is_le;
1160+
11591161
if (!vq->private_data) {
11601162
vq->is_le = virtio_legacy_is_little_endian();
11611163
return 0;
@@ -1165,15 +1167,20 @@ int vhost_init_used(struct vhost_virtqueue *vq)
11651167

11661168
r = vhost_update_used_flags(vq);
11671169
if (r)
1168-
return r;
1170+
goto err;
11691171
vq->signalled_used_valid = false;
1170-
if (!access_ok(VERIFY_READ, &vq->used->idx, sizeof vq->used->idx))
1171-
return -EFAULT;
1172+
if (!access_ok(VERIFY_READ, &vq->used->idx, sizeof vq->used->idx)) {
1173+
r = -EFAULT;
1174+
goto err;
1175+
}
11721176
r = __get_user(last_used_idx, &vq->used->idx);
11731177
if (r)
1174-
return r;
1178+
goto err;
11751179
vq->last_used_idx = vhost16_to_cpu(vq, last_used_idx);
11761180
return 0;
1181+
err:
1182+
vq->is_le = is_le;
1183+
return r;
11771184
}
11781185
EXPORT_SYMBOL_GPL(vhost_init_used);
11791186

drivers/virtio/virtio_pci_modern.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ int virtio_pci_modern_probe(struct virtio_pci_device *vp_dev)
679679

680680
pci_read_config_dword(pci_dev,
681681
notify + offsetof(struct virtio_pci_notify_cap,
682-
cap.length),
682+
cap.offset),
683683
&notify_offset);
684684

685685
/* We don't know how many VQs we'll map, ahead of the time.

0 commit comments

Comments
 (0)