From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:39060) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLAuR-0008M0-Tp for qemu-devel@nongnu.org; Mon, 08 Oct 2012 06:50:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TLAuL-0006eS-Ba for qemu-devel@nongnu.org; Mon, 08 Oct 2012 06:50:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:13686) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLAuL-0006e5-1k for qemu-devel@nongnu.org; Mon, 08 Oct 2012 06:49:57 -0400 From: Gerd Hoffmann Date: Mon, 8 Oct 2012 12:49:45 +0200 Message-Id: <1349693391-32704-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1349693391-32704-1-git-send-email-kraxel@redhat.com> References: <1349693391-32704-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 2/8] qxl/update_area_io: cleanup invalid parameters handling List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alon Levy , Michael Tokarev , Gerd Hoffmann , Dunrong Huang From: Michael Tokarev This cleans up two additions of almost the same code in commits 511b13e2c9 and ccc2960d654. While at it, make error paths consistent (always use 'break' instead of 'return'). Signed-off-by: Michael Tokarev Cc: Dunrong Huang Cc: Alon Levy Signed-off-by: Gerd Hoffmann --- hw/qxl.c | 13 +++---------- 1 files changed, 3 insertions(+), 10 deletions(-) diff --git a/hw/qxl.c b/hw/qxl.c index 33169f3..3c82c2a 100644 --- a/hw/qxl.c +++ b/hw/qxl.c @@ -1547,20 +1547,13 @@ async_common: if (d->ram->update_surface > d->ssd.num_surfaces) { qxl_set_guest_bug(d, "QXL_IO_UPDATE_AREA: invalid surface id %d\n", d->ram->update_surface); - return; + break; } - if (update.left >= update.right || update.top >= update.bottom) { + if (update.left >= update.right || update.top >= update.bottom || + update.left < 0 || update.top < 0) { qxl_set_guest_bug(d, "QXL_IO_UPDATE_AREA: invalid area (%ux%u)x(%ux%u)\n", update.left, update.top, update.right, update.bottom); - return; - } - - if (update.left < 0 || update.top < 0 || update.left >= update.right || - update.top >= update.bottom) { - qxl_set_guest_bug(d, "QXL_IO_UPDATE_AREA: " - "invalid area(%d,%d,%d,%d)\n", update.left, - update.right, update.top, update.bottom); break; } if (async == QXL_ASYNC) { -- 1.7.1