From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55507) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4p2a-00041S-4b for qemu-devel@nongnu.org; Mon, 23 May 2016 08:33:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b4p2S-0008IJ-Mm for qemu-devel@nongnu.org; Mon, 23 May 2016 08:33:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35462) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4p2S-0008Hf-FI for qemu-devel@nongnu.org; Mon, 23 May 2016 08:32:52 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (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 5AB1780E42 for ; Mon, 23 May 2016 12:32:50 +0000 (UTC) From: Gerd Hoffmann Date: Mon, 23 May 2016 14:32:40 +0200 Message-Id: <1464006764-8115-5-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 4/7] virtio-gpu: check max_outputs only 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 scanout id should not be above the configured num_scanouts. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-id: 1463653560-26958-5-git-send-email-marcandre.lureau@redhat.com Signed-off-by: Gerd Hoffmann --- hw/display/virtio-gpu-3d.c | 4 ++-- hw/display/virtio-gpu.c | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/hw/display/virtio-gpu-3d.c b/hw/display/virtio-gpu-3d.c index 20e8865..433bf93 100644 --- a/hw/display/virtio-gpu-3d.c +++ b/hw/display/virtio-gpu-3d.c @@ -128,7 +128,7 @@ static void virgl_cmd_resource_flush(VirtIOGPU *g, trace_virtio_gpu_cmd_res_flush(rf.resource_id, rf.r.width, rf.r.height, rf.r.x, rf.r= .y); =20 - for (i =3D 0; i < VIRTIO_GPU_MAX_SCANOUT; i++) { + for (i =3D 0; i < g->conf.max_outputs; i++) { if (g->scanout[i].resource_id !=3D rf.resource_id) { continue; } @@ -147,7 +147,7 @@ static void virgl_cmd_set_scanout(VirtIOGPU *g, trace_virtio_gpu_cmd_set_scanout(ss.scanout_id, ss.resource_id, ss.r.width, ss.r.height, ss.r.x, ss= .r.y); =20 - if (ss.scanout_id >=3D VIRTIO_GPU_MAX_SCANOUT) { + if (ss.scanout_id >=3D g->conf.max_outputs) { qemu_log_mask(LOG_GUEST_ERROR, "%s: illegal scanout id specified= %d", __func__, ss.scanout_id); cmd->error =3D VIRTIO_GPU_RESP_ERR_INVALID_SCANOUT_ID; diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 7114021..643dd92 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -466,7 +466,7 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g, =20 pixman_region_init_rect(&flush_region, rf.r.x, rf.r.y, rf.r.width, rf.r.height); - for (i =3D 0; i < VIRTIO_GPU_MAX_SCANOUT; i++) { + for (i =3D 0; i < g->conf.max_outputs; i++) { struct virtio_gpu_scanout *scanout; pixman_region16_t region, finalregion; pixman_box16_t *extents; @@ -509,8 +509,7 @@ static void virtio_gpu_set_scanout(VirtIOGPU *g, trace_virtio_gpu_cmd_set_scanout(ss.scanout_id, ss.resource_id, ss.r.width, ss.r.height, ss.r.x, ss= .r.y); =20 - if (ss.scanout_id >=3D VIRTIO_GPU_MAX_SCANOUT || - ss.scanout_id >=3D g->conf.max_outputs) { + if (ss.scanout_id >=3D g->conf.max_outputs) { qemu_log_mask(LOG_GUEST_ERROR, "%s: illegal scanout id specified= %d", __func__, ss.scanout_id); cmd->error =3D VIRTIO_GPU_RESP_ERR_INVALID_SCANOUT_ID; --=20 1.8.3.1