From: Michael S. Tsirkin Date: Mon, 12 May 2014 09:04:20 +0000 (+0300) Subject: virtio: allow mapping up to max queue size X-Git-Tag: qemu-xen-4.5.0-rc1^2~75 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=3ba1e617e7ae2b69a508a52b4f6cc301a9de95ce;p=qemu-upstream-4.5-testing.git virtio: allow mapping up to max queue size It's a loop from i < num_sg and the array is VIRTQUEUE_MAX_SIZE - so it's OK if the value read is VIRTQUEUE_MAX_SIZE. Not a big problem in practice as people don't use such big queues, but it's inelegant. Reported-by: "Dr. David Alan Gilbert" Cc: qemu-stable@nongnu.org Signed-off-by: Michael S. Tsirkin (cherry picked from commit 937251408051e0489f78e4db3c92e045b147b38b) Signed-off-by: Michael Roth --- diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index abfc4e9ce..6523e62c2 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -430,7 +430,7 @@ void virtqueue_map_sg(struct iovec *sg, hwaddr *addr, unsigned int i; hwaddr len; - if (num_sg >= VIRTQUEUE_MAX_SIZE) { + if (num_sg > VIRTQUEUE_MAX_SIZE) { error_report("virtio: map attempt out of bounds: %zd > %d", num_sg, VIRTQUEUE_MAX_SIZE); exit(1);