From patchwork Wed Sep 19 13:41:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 185040 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8BF5C2C0084 for ; Wed, 19 Sep 2012 23:42:02 +1000 (EST) Received: from localhost ([::1]:41123 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEKXQ-0005SQ-7q for incoming@patchwork.ozlabs.org; Wed, 19 Sep 2012 09:42:00 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34243) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEKXD-0005Rv-VJ for qemu-devel@nongnu.org; Wed, 19 Sep 2012 09:41:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TEKX7-0000bx-Sz for qemu-devel@nongnu.org; Wed, 19 Sep 2012 09:41:47 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:39345) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEKX7-0000V8-Lq for qemu-devel@nongnu.org; Wed, 19 Sep 2012 09:41:41 -0400 Received: from gandalf.tls.msk.ru (mjt.vpn.tls.msk.ru [192.168.177.99]) by isrv.corpit.ru (Postfix) with ESMTP id 95347A12F6; Wed, 19 Sep 2012 17:41:33 +0400 (MSK) Received: by gandalf.tls.msk.ru (Postfix, from userid 1000) id 561ED4BD; Wed, 19 Sep 2012 17:41:33 +0400 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Date: Wed, 19 Sep 2012 17:41:26 +0400 Message-Id: <1348062086-23490-1-git-send-email-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 1.7.10.4 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 86.62.121.231 Cc: Alon Levy , Michael Tokarev , Gerd Hoffmann , Dunrong Huang Subject: [Qemu-devel] [PATCH] qxl/update_area_io: cleanup invalid parameters handling 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 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 --- hw/qxl.c | 13 +++---------- 1 file 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) {