From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55487) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4p2Y-00040U-Nb for qemu-devel@nongnu.org; Mon, 23 May 2016 08:33:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b4p2S-0008I8-KY for qemu-devel@nongnu.org; Mon, 23 May 2016 08:32:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34002) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4p2S-0008Hd-FE for qemu-devel@nongnu.org; Mon, 23 May 2016 08:32:52 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7147881137 for ; Mon, 23 May 2016 12:32:50 +0000 (UTC) From: Gerd Hoffmann Date: Mon, 23 May 2016 14:32:39 +0200 Message-Id: <1464006764-8115-4-git-send-email-kraxel@redhat.com> In-Reply-To: <1464006764-8115-1-git-send-email-kraxel@redhat.com> References: <1464006764-8115-1-git-send-email-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 3/7] virtio-gpu: check max_outputs value List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , "Michael S. Tsirkin" From: Marc-Andr=C3=A9 Lureau The value must be less than VIRTIO_GPU_MAX_SCANOUT. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-id: 1463653560-26958-4-git-send-email-marcandre.lureau@redhat.com Signed-off-by: Gerd Hoffmann --- 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 64a60f2..7114021 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -20,6 +20,7 @@ #include "hw/virtio/virtio-gpu.h" #include "hw/virtio/virtio-bus.h" #include "qemu/log.h" +#include "qapi/error.h" =20 static struct virtio_gpu_simple_resource* virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id); @@ -929,6 +930,11 @@ static void virtio_gpu_device_realize(DeviceState *q= dev, Error **errp) bool have_virgl; int i; =20 + if (g->conf.max_outputs > VIRTIO_GPU_MAX_SCANOUT) { + error_setg(errp, "invalid max_outputs > %d", VIRTIO_GPU_MAX_SCAN= OUT); + return; + } + g->config_size =3D sizeof(struct virtio_gpu_config); g->virtio_config.num_scanouts =3D g->conf.max_outputs; virtio_init(VIRTIO_DEVICE(g), "virtio-gpu", VIRTIO_ID_GPU, --=20 1.8.3.1