From: Amos Kong Subject: [PATCH 2/3] virtio: Strictly check queue_size when adding virtqueue Date: Wed, 15 Jun 2011 22:25:33 +0800 Message-ID: <20110615142533.26726.54603.stgit@localhost6.localdomain6> References: <20110615142524.26726.13785.stgit@localhost6.localdomain6> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: mst@redhat.com Return-path: Received: from mx1.redhat.com ([209.132.183.28]:17705 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754966Ab1FOOZh (ORCPT ); Wed, 15 Jun 2011 10:25:37 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p5FEPaLs003514 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 15 Jun 2011 10:25:36 -0400 In-Reply-To: <20110615142524.26726.13785.stgit@localhost6.localdomain6> Sender: kvm-owner@vger.kernel.org List-ID: Qemu should abort when 'queue_size' is less than or equals to zero. Signed-off-by: Amos Kong --- hw/virtio.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/hw/virtio.c b/hw/virtio.c index a3d0eee..855fe54 100644 --- a/hw/virtio.c +++ b/hw/virtio.c @@ -612,7 +612,8 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size, break; } - if (i == VIRTIO_PCI_QUEUE_MAX || queue_size > VIRTQUEUE_MAX_SIZE) + if (i == VIRTIO_PCI_QUEUE_MAX || queue_size > VIRTQUEUE_MAX_SIZE || + queue_size <= 0) abort(); vdev->vq[i].vring.num = queue_size;