From patchwork Mon Jan 20 14:20:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alon Levy X-Patchwork-Id: 312607 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 98BDF2C0078 for ; Tue, 21 Jan 2014 01:55:28 +1100 (EST) Received: from localhost ([::1]:52361 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W5Fmo-0008Oi-Ny for incoming@patchwork.ozlabs.org; Mon, 20 Jan 2014 09:25:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48881) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W5FiN-0002J2-MU for qemu-devel@nongnu.org; Mon, 20 Jan 2014 09:20:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W5FiH-0006Vz-LS for qemu-devel@nongnu.org; Mon, 20 Jan 2014 09:20:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:4315) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W5FiH-0006VK-Ah for qemu-devel@nongnu.org; Mon, 20 Jan 2014 09:20:29 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0KEKQXW027098 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 20 Jan 2014 09:20:26 -0500 Received: from blues.com (vpn1-4-242.ams2.redhat.com [10.36.4.242]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s0KEKOHu026159; Mon, 20 Jan 2014 09:20:24 -0500 From: Alon Levy To: qemu-devel@nongnu.org Date: Mon, 20 Jan 2014 16:20:20 +0200 Message-Id: <1390227620-23771-1-git-send-email-alevy@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: peter.maydell@linaro.org, kraxel@redhat.com, armbru@redhat.com Subject: [Qemu-devel] [PATCH v3] hw/display/qxl: fix signed to unsigned comparison X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Several small signedness / overflow corrections to qxl_create_guest_primary: 1. use 64 bit unsigned for size to avoid overflow possible from two 32 bit multiplicants. 2. correct sign for requested_height 3. add a more verbose error message when setting guest bug state (which causes a complete guess blackout until reset, so it helps if it is verbose). Signed-off-by: Alon Levy --- hw/display/qxl.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/display/qxl.c b/hw/display/qxl.c index e4f172e..ba752b5 100644 --- a/hw/display/qxl.c +++ b/hw/display/qxl.c @@ -1360,14 +1360,15 @@ static void qxl_create_guest_primary(PCIQXLDevice *qxl, int loadvm, { QXLDevSurfaceCreate surface; QXLSurfaceCreate *sc = &qxl->guest_primary.surface; - int size; - int requested_height = le32_to_cpu(sc->height); + uint64_t size; + uint32_t requested_height = le32_to_cpu(sc->height); int requested_stride = le32_to_cpu(sc->stride); size = abs(requested_stride) * requested_height; if (size > qxl->vgamem_size) { - qxl_set_guest_bug(qxl, "%s: requested primary larger then framebuffer" - " size", __func__); + qxl_set_guest_bug(qxl, "%s: requested primary larger than framebuffer" + " size %" PRIu64 " > %" PRIu32, __func__, size, + qxl->vgamem_size); return; }