[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 11/19] virtio: handle virtqueue_get_avail_bytes() err
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 11/19] virtio: handle virtqueue_get_avail_bytes() errors |
Date: |
Fri, 23 Sep 2016 22:57:29 +0300 |
From: Stefan Hajnoczi <address@hidden>
If the vring is invalid, tell the caller no bytes are available and mark
the device broken.
Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Cornelia Huck <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
Reviewed-by: Cornelia Huck <address@hidden>
---
hw/virtio/virtio.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index f2d6c3c..10c2f3d 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -426,14 +426,14 @@ void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned
int *in_bytes,
if (desc.flags & VRING_DESC_F_INDIRECT) {
if (desc.len % sizeof(VRingDesc)) {
- error_report("Invalid size for indirect buffer table");
- exit(1);
+ virtio_error(vdev, "Invalid size for indirect buffer table");
+ goto err;
}
/* If we've got too many, that implies a descriptor loop. */
if (num_bufs >= max) {
- error_report("Looped descriptor");
- exit(1);
+ virtio_error(vdev, "Looped descriptor");
+ goto err;
}
/* loop over the indirect descriptor table */
@@ -447,8 +447,8 @@ void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int
*in_bytes,
do {
/* If we've got too many, that implies a descriptor loop. */
if (++num_bufs > max) {
- error_report("Looped descriptor");
- exit(1);
+ virtio_error(vdev, "Looped descriptor");
+ goto err;
}
if (desc.flags & VRING_DESC_F_WRITE) {
@@ -473,6 +473,11 @@ done:
if (out_bytes) {
*out_bytes = out_total;
}
+ return;
+
+err:
+ in_total = out_total = 0;
+ goto done;
}
int virtqueue_avail_bytes(VirtQueue *vq, unsigned int in_bytes,
--
MST
- [Qemu-devel] [PULL 02/19] tests: add a simple /vhost-user/multiqueue test, (continued)
- [Qemu-devel] [PULL 02/19] tests: add a simple /vhost-user/multiqueue test, Michael S. Tsirkin, 2016/09/23
- [Qemu-devel] [PULL 03/19] tests: add /vhost-user/flags-mismatch test, Michael S. Tsirkin, 2016/09/23
- [Qemu-devel] [PULL 04/19] virtio: add check for descriptor's mapped address, Michael S. Tsirkin, 2016/09/23
- [Qemu-devel] [PULL 05/19] pc: clean up COMPAT macro chaining, Michael S. Tsirkin, 2016/09/23
- [Qemu-devel] [PULL 06/19] target-i386: turn off CPU.l3-cache only for 2.7 and older machine types, Michael S. Tsirkin, 2016/09/23
- [Qemu-devel] [PULL 09/19] virtio: migrate vdev->broken flag, Michael S. Tsirkin, 2016/09/23
- [Qemu-devel] [PULL 07/19] virtio: fix stray tab character, Michael S. Tsirkin, 2016/09/23
- [Qemu-devel] [PULL 08/19] virtio: stop virtqueue processing if device is broken, Michael S. Tsirkin, 2016/09/23
- [Qemu-devel] [PULL 10/19] virtio: handle virtqueue_map_desc() errors, Michael S. Tsirkin, 2016/09/23
- [Qemu-devel] [PULL 12/19] virtio: use unsigned int for virtqueue_get_avail_bytes() index, Michael S. Tsirkin, 2016/09/23
- [Qemu-devel] [PULL 11/19] virtio: handle virtqueue_get_avail_bytes() errors,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 14/19] virtio: handle virtqueue_num_heads() errors, Michael S. Tsirkin, 2016/09/23
- [Qemu-devel] [PULL 15/19] virtio: handle virtqueue_get_head() errors, Michael S. Tsirkin, 2016/09/23
- [Qemu-devel] [PULL 13/19] virtio: handle virtqueue_read_next_desc() errors, Michael S. Tsirkin, 2016/09/23
- [Qemu-devel] [PULL 16/19] hw/pci: Prepare for AMD IOMMU, Michael S. Tsirkin, 2016/09/23
- [Qemu-devel] [PULL 17/19] hw/i386/trace-events: Add AMD IOMMU trace events, Michael S. Tsirkin, 2016/09/23
- [Qemu-devel] [PULL 19/19] hw/i386: AMD IOMMU IVRS table, Michael S. Tsirkin, 2016/09/23
- [Qemu-devel] [PULL 18/19] hw/i386: Introduce AMD IOMMU, Michael S. Tsirkin, 2016/09/23
- Re: [Qemu-devel] [PULL 00/19] virtio, pc: fixes and features, no-reply, 2016/09/23
- Re: [Qemu-devel] [PULL 00/19] virtio, pc: fixes and features, no-reply, 2016/09/23