Received: from eggs.gnu.org ([2001:4830:134:3::10]:48291) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b3L9k-00056z-Ud for qemu-devel@nongnu.org; Thu, 19 May 2016 06:26:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b3L9g-0005Rz-1N for qemu-devel@nongnu.org; Thu, 19 May 2016 06:26:15 -0400 Received: from mail-qk0-x243.google.com ([2607:f8b0:400d:c09::243]:33327) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b3L9f-0005Rp-TT for qemu-devel@nongnu.org; Thu, 19 May 2016 06:26:11 -0400 Received: by mail-qk0-x243.google.com with SMTP id q184so7131181qkf.0 for ; Thu, 19 May 2016 03:26:11 -0700 (PDT) Sender: =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= From: marcandre.lureau@redhat.com Date: Thu, 19 May 2016 12:25:57 +0200 Message-Id: <1463653560-26958-4-git-send-email-marcandre.lureau@redhat.com> In-Reply-To: <1463653560-26958-1-git-send-email-marcandre.lureau@redhat.com> References: <1463653560-26958-1-git-send-email-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH 3/6] virtio-gpu: check max_outputs value List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= From: Marc-André Lureau The value must be less than VIRTIO_GPU_MAX_SCANOUT. Signed-off-by: Marc-André Lureau --- hw/display/virtio-gpu.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 1193838..77e542f 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -19,6 +19,7 @@ #include "hw/virtio/virtio.h" #include "hw/virtio/virtio-gpu.h" #include "hw/virtio/virtio-bus.h" +#include "qapi/error.h" static struct virtio_gpu_simple_resource* virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id); @@ -928,6 +929,11 @@ static void virtio_gpu_device_realize(DeviceState *qdev, Error **errp) bool have_virgl; int i; + if (g->conf.max_outputs > VIRTIO_GPU_MAX_SCANOUT) { + error_setg(errp, "invalid max_outputs > %d", VIRTIO_GPU_MAX_SCANOUT); + return; + } + g->config_size = sizeof(struct virtio_gpu_config); g->virtio_config.num_scanouts = g->conf.max_outputs; virtio_init(VIRTIO_DEVICE(g), "virtio-gpu", VIRTIO_ID_GPU, -- 2.7.4