From: Ville Syrjälä Date: Wed, 14 Dec 2011 22:11:47 +0000 (+0200) Subject: drm: plane: Check source coordinates X-Git-Tag: 2.1b_release~449 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=297785489997f74fbf09208b41f7c78aaf43890e;p=kernel%2Fkernel-mfld-blackbay.git drm: plane: Check source coordinates Make sure the source coordinates stay within the buffer. Signed-off-by: Ville Syrjälä Acked-by: Pauli Nieminen Reviewed-by: Jani Nikula Signed-off-by: Kirill A. Shutemov --- diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 7eecf73..53c5607 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -1659,6 +1659,7 @@ int drm_mode_setplane(struct drm_device *dev, void *data, struct drm_crtc *crtc; struct drm_framebuffer *fb; int ret = 0; + unsigned int fb_width, fb_height; if (!drm_core_check_feature(dev, DRIVER_MODESET)) return -EINVAL; @@ -1707,6 +1708,28 @@ int drm_mode_setplane(struct drm_device *dev, void *data, } fb = obj_to_fb(obj); + fb_width = fb->width << 16; + fb_height = fb->height << 16; + + /* Make sure source coordinates are inside the fb. */ + if (plane_req->src_w > fb_width || + plane_req->src_x > fb_width - plane_req->src_w || + plane_req->src_h > fb_height || + plane_req->src_y > fb_height - plane_req->src_h) { + DRM_DEBUG_KMS("Invalid source coordinates " + "%01u.%06ux%01u.%06u+%01u.%06u+%01u.%06u\n", + plane_req->src_w >> 16, + ((plane_req->src_w & 0xffff) * 15625) >> 10, + plane_req->src_h >> 16, + ((plane_req->src_h & 0xffff) * 15625) >> 10, + plane_req->src_x >> 16, + ((plane_req->src_x & 0xffff) * 15625) >> 10, + plane_req->src_y >> 16, + ((plane_req->src_y & 0xffff) * 15625) >> 10); + ret = -ENOSPC; + goto out; + } + ret = plane->funcs->update_plane(plane, crtc, fb, plane_req->crtc_x, plane_req->crtc_y, plane_req->crtc_w, plane_req->crtc_h,