drm/i915: Clamp cursor coordinates to int16_t range
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Mon, 21 Oct 2013 16:01:58 +0000 (19:01 +0300)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Mon, 28 Oct 2013 16:56:00 +0000 (17:56 +0100)
We store cursor_x/y as int16_t internally, but the user provided
coordinates are int32_t. Clamp the coordinates so that they don't
overflow the int16_t. Since the cursor is only 64x64 in size, the
clamping can't cause any visual changes.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/intel_display.c

index 8c3bf8a89cb795b31c23b4b4e7ca5c52ecbefe87..c69a5b844f5ab5f3bce3fdd48ef6dbe4c40ccac1 100644 (file)
@@ -7333,8 +7333,8 @@ static int intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
 {
        struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 
-       intel_crtc->cursor_x = x;
-       intel_crtc->cursor_y = y;
+       intel_crtc->cursor_x = clamp_t(int, x, SHRT_MIN, SHRT_MAX);
+       intel_crtc->cursor_y = clamp_t(int, y, SHRT_MIN, SHRT_MAX);
 
        if (intel_crtc->active)
                intel_crtc_update_cursor(crtc, intel_crtc->cursor_bo != NULL);