summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2013-06-30 18:43:52 +0300
committerAlon Levy <alevy@redhat.com>2013-07-17 18:23:52 +0300
commit855607b9daa44cb24ceaaf27f1de7aa51d509919 (patch)
tree2786d8c8fc74574505b5a721d16ade50c4c50ecc
parentadb0148d6eadf68668d9994078515453070b2919 (diff)
miniport/qxl.c: fail a custom mode that would not fit memory (RHBZ#863488)
Signed-off-by: Alon Levy <alevy@redhat.com> (cherry picked from commit 85de1534831a63ebcb682a10d4cd509467f4e5d0)
-rw-r--r--miniport/qxl.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/miniport/qxl.c b/miniport/qxl.c
index 58ba15e..69d1b16 100644
--- a/miniport/qxl.c
+++ b/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;