From: Ville Syrjälä Date: Tue, 20 Mar 2012 14:46:05 +0000 (+0200) Subject: drm: Warn if mode to umode conversion overflows the destination types X-Git-Tag: 2.1b_release~206 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7ed972e883070d693cc6ce4564b2605079ba93cf;p=kernel%2Fkernel-mfld-blackbay.git drm: Warn if mode to umode conversion overflows the destination types When converting from a drm_display_mode to drm_mode_modeinfo, print a warning if the the timings values don't fit into the __u16 datatype. Signed-off-by: Ville Syrjälä Reviewed-by: Alex Deucher Signed-off-by: Dave Airlie Signed-off-by: Kirill A. Shutemov --- diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index d414775..c1310df 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -1052,6 +1052,13 @@ EXPORT_SYMBOL(drm_mode_config_cleanup); void drm_crtc_convert_to_umode(struct drm_mode_modeinfo *out, struct drm_display_mode *in) { + WARN(in->hdisplay > USHRT_MAX || in->hsync_start > USHRT_MAX || + in->hsync_end > USHRT_MAX || in->htotal > USHRT_MAX || + in->hskew > USHRT_MAX || in->vdisplay > USHRT_MAX || + in->vsync_start > USHRT_MAX || in->vsync_end > USHRT_MAX || + in->vtotal > USHRT_MAX || in->vscan > USHRT_MAX, + "timing values too large for mode info\n"); + out->clock = in->clock; out->hdisplay = in->hdisplay; out->hsync_start = in->hsync_start;