diff options
author | Ville Syrjälä <ville.syrjala@linux.intel.com> | 2012-03-13 12:35:45 +0200 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2012-03-15 09:51:04 +0000 |
commit | 5f61bb421f01023986902200b6486978c07176f7 (patch) | |
tree | f78812553cc5a6b0a6ea9de018744b3ac2fbd426 /drivers/gpu/drm/drm_crtc.c | |
parent | 90367bf6e98352520d15634ac4e79f0d4598cff1 (diff) | |
download | blackbird-op-linux-5f61bb421f01023986902200b6486978c07176f7.tar.gz blackbird-op-linux-5f61bb421f01023986902200b6486978c07176f7.zip |
drm: Check CRTC viewport against framebuffer size
Make sure the requested CRTC viewport fits inside the
framebuffer.
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/drm_crtc.c')
-rw-r--r-- | drivers/gpu/drm/drm_crtc.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 4d9e69cb2354..3f5c603f9a2c 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -1835,6 +1835,18 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, } drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V); + + if (mode->hdisplay > fb->width || + mode->vdisplay > fb->height || + crtc_req->x > fb->width - mode->hdisplay || + crtc_req->y > fb->height - mode->vdisplay) { + DRM_DEBUG_KMS("Invalid CRTC viewport %ux%u+%u+%u for fb size %ux%u.\n", + mode->hdisplay, mode->vdisplay, + crtc_req->x, crtc_req->y, + fb->width, fb->height); + ret = -ENOSPC; + goto out; + } } if (crtc_req->count_connectors == 0 && mode) { @@ -3206,6 +3218,18 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, goto out; fb = obj_to_fb(obj); + if (crtc->mode.hdisplay > fb->width || + crtc->mode.vdisplay > fb->height || + crtc->x > fb->width - crtc->mode.hdisplay || + crtc->y > fb->height - crtc->mode.vdisplay) { + DRM_DEBUG_KMS("Invalid fb size %ux%u for CRTC viewport %ux%u+%d+%d.\n", + fb->width, fb->height, + crtc->mode.hdisplay, crtc->mode.vdisplay, + crtc->x, crtc->y); + ret = -ENOSPC; + goto out; + } + if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT) { ret = -ENOMEM; spin_lock_irqsave(&dev->event_lock, flags); |