From 7212feff030ca1bb9bd689b682509411fc6dbab0 Mon Sep 17 00:00:00 2001 From: Michael S. Tsirkin Date: Tue, 13 May 2014 08:03:37 -0500 Subject: [PATCH 17/20] virtio: allow mapping up to max queue size RH-Author: Michael S. Tsirkin Message-id: <1399968167-29364-2-git-send-email-mst@redhat.com> Patchwork-id: 58813 O-Subject: [PATCH qemu-kvm RHEL6.6 v3 2/2] virtio: allow mapping up to max queue size Bugzilla: 1096124 RH-Acked-by: Juan Quintela RH-Acked-by: Stefan Hajnoczi RH-Acked-by: Marcel Apfelbaum RH-Acked-by: Xiao Wang 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 Upstream: 937251408051e0489f78e4db3c92e045b147b38b (note: maintainer's tree at this point: git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git pci) Bugzilla: 1096093 Tested: lightly on developer's box Brew build: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=7443590 --- hw/virtio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Signed-off-by: Jeff E. Nelson --- hw/virtio.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/hw/virtio.c b/hw/virtio.c index d1f9974..14d2ee6 100644 --- a/hw/virtio.c +++ b/hw/virtio.c @@ -424,7 +424,7 @@ void virtqueue_map_sg(struct iovec *sg, target_phys_addr_t *addr, unsigned int i; target_phys_addr_t 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); -- 1.7.1