From: Dan Carpenter Date: Wed, 27 Nov 2013 22:18:47 +0000 (+0300) Subject: drm/nv50/disp: min/max are reversed in nv50_crtc_gamma_set() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c4c175dbd7c40e14393a83065edc14f147c5a087;p=GitHub%2Fmt8127%2Fandroid_kernel_alcatel_ttab.git drm/nv50/disp: min/max are reversed in nv50_crtc_gamma_set() commit bdefc8cbdfc71ea73e0573dbd2d24c0a68232218 upstream. We should be taking the minimum here instead of the max. It could lead to a buffer overflow. Fixes: 438d99e3b175 ('drm/nvd0/disp: initial crtc object implementation') Signed-off-by: Dan Carpenter a/drm/nv50_display.c b/drm/nv50_display.c index f8e66c08b11a..4e384a2f99c3 100644 Signed-off-by: Jiri Slaby Signed-off-by: Willy Tarreau --- diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c index dd5e01f89f28..969acd36c409 100644 --- a/drivers/gpu/drm/nouveau/nv50_display.c +++ b/drivers/gpu/drm/nouveau/nv50_display.c @@ -1253,7 +1253,7 @@ nv50_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, uint32_t start, uint32_t size) { struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); - u32 end = max(start + size, (u32)256); + u32 end = min_t(u32, start + size, 256); u32 i; for (i = start; i < end; i++) {