From 244a182e16d94ee0a84c0a694f23871c5afa1062 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Wed, 2 Jul 2014 12:18:46 -0500
Subject: [CHANGE 02/11] qxl/update_area_io: cleanup invalid parameters
 handling
To: rhvirt-patches@redhat.com,
    jen@redhat.com

RH-Author: Gerd Hoffmann <kraxel@redhat.com>
Message-id: <1404303526-29203-3-git-send-email-kraxel@redhat.com>
Patchwork-id: 59443
O-Subject: [RHEL-6.6 qemu-kvm PATCH 2/2] qxl/update_area_io: cleanup invalid parameters handling
Bugzilla: 994388
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>

From: Michael Tokarev <mjt@tls.msk.ru>

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 <mjt@tls.msk.ru>
Cc: Dunrong Huang <riegamaths@gmail.com>
Cc: Alon Levy <alevy@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 36a03e0ba5202cf49749b2128bb62d41983681d6)
Signed-off-by: jen <jen@redhat.com>
---
 hw/qxl.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/hw/qxl.c b/hw/qxl.c
index 9c519e2..0d8edeb 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -1548,20 +1548,13 @@ async_common:
         if (d->ram->update_surface > 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.9.3

