[Spice-commits] xddm/miniport

Alon Levy alon at kemper.freedesktop.org
Mon Jul 1 05:47:04 PDT 2013


 xddm/miniport/qxl.c |   26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

New commits:
commit 85de1534831a63ebcb682a10d4cd509467f4e5d0
Author: Alon Levy <alevy at redhat.com>
Date:   Sun Jun 30 18:43:52 2013 +0300

    miniport/qxl.c: fail a custom mode that would not fit memory (RHBZ#863488)
    
    Signed-off-by: Alon Levy <alevy at redhat.com>

diff --git a/xddm/miniport/qxl.c b/xddm/miniport/qxl.c
index 58ba15e..69d1b16 100644
--- a/xddm/miniport/qxl.c
+++ b/xddm/miniport/qxl.c
@@ -994,16 +994,29 @@ PVIDEO_MODE_INFORMATION FindMode(QXLExtension *dev_ext, ULONG mode)
 
 static VP_STATUS SetCustomDisplay(QXLExtension *dev_ext, QXLEscapeSetCustomDisplay *custom_display)
 {
+    VP_STATUS ret;
+    uint32_t xres = custom_display->xres;
+    uint32_t yres = custom_display->yres;
+    uint32_t bpp = custom_display->bpp;
+
     /* alternate custom mode index */
     if (dev_ext->custom_mode == (dev_ext->n_modes - 1))
         dev_ext->custom_mode = dev_ext->n_modes - 2;
     else
         dev_ext->custom_mode = dev_ext->n_modes - 1;
 
-    return FillVidModeInfo(&dev_ext->modes[dev_ext->custom_mode],
-                           custom_display->xres, custom_display->yres,
-                           custom_display->bpp,
-                           dev_ext->custom_mode);
+    if ((xres * yres * bpp / 8) > dev_ext->rom->surface0_area_size) {
+        DEBUG_PRINT((dev_ext, 0, "%s: Mode (%dx%d#%d) doesn't fit in memory (%d)\n",
+                    __FUNCTION__, xres, yres, bpp, dev_ext->rom->surface0_area_size));
+        return ERROR_NOT_ENOUGH_MEMORY;
+    }
+
+    ret = FillVidModeInfo(&dev_ext->modes[dev_ext->custom_mode],
+                          custom_display->xres, custom_display->yres,
+                          custom_display->bpp,
+                          dev_ext->custom_mode);
+    DEBUG_PRINT((dev_ext, 0, "%s: Returning %d\n", __FUNCTION__, ret));
+    return ret;
 }
 
 VP_STATUS QXLRegistryCallback(
@@ -1254,7 +1267,10 @@ BOOLEAN StartIO(PVOID dev_extension, PVIDEO_REQUEST_PACKET packet)
             DEBUG_PRINT((dev_ext, 0, "%s: %dx%d@%d\n", __FUNCTION__,
                          custom_display->xres, custom_display->yres,
                          custom_display->bpp));
-            SetCustomDisplay(dev_ext, custom_display);
+            error = SetCustomDisplay(dev_ext, custom_display);
+            if (error != NO_ERROR) {
+                goto err;
+            }
         }
         break;
 


More information about the Spice-commits mailing list