aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_crtc.c
diff options
context:
space:
mode:
authorVille Syrjälä <ville.syrjala@linux.intel.com>2012-10-25 14:05:04 -0400
committerDave Airlie <airlied@redhat.com>2012-11-06 19:09:09 -0500
commitb180b5d1c7ac930387734664802fc26fa788e26f (patch)
tree1c86676c401d2eb6c252b412155780306d9eac7d /drivers/gpu/drm/drm_crtc.c
parent3d70f8c617a436c7146ecb81df2265b4626dfe89 (diff)
drm: Be more paranoid with integer overflows
Make sure 'width * cpp' and 'height * pitch + offset' don't exceed UINT_MAX. 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.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index ef1b22144d37..d9a639c870f4 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -2280,13 +2280,21 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r)
2280 2280
2281 for (i = 0; i < num_planes; i++) { 2281 for (i = 0; i < num_planes; i++) {
2282 unsigned int width = r->width / (i != 0 ? hsub : 1); 2282 unsigned int width = r->width / (i != 0 ? hsub : 1);
2283 unsigned int height = r->height / (i != 0 ? vsub : 1);
2284 unsigned int cpp = drm_format_plane_cpp(r->pixel_format, i);
2283 2285
2284 if (!r->handles[i]) { 2286 if (!r->handles[i]) {
2285 DRM_DEBUG_KMS("no buffer object handle for plane %d\n", i); 2287 DRM_DEBUG_KMS("no buffer object handle for plane %d\n", i);
2286 return -EINVAL; 2288 return -EINVAL;
2287 } 2289 }
2288 2290
2289 if (r->pitches[i] < drm_format_plane_cpp(r->pixel_format, i) * width) { 2291 if ((uint64_t) width * cpp > UINT_MAX)
2292 return -ERANGE;
2293
2294 if ((uint64_t) height * r->pitches[i] + r->offsets[i] > UINT_MAX)
2295 return -ERANGE;
2296
2297 if (r->pitches[i] < width * cpp) {
2290 DRM_DEBUG_KMS("bad pitch %u for plane %d\n", r->pitches[i], i); 2298 DRM_DEBUG_KMS("bad pitch %u for plane %d\n", r->pitches[i], i);
2291 return -EINVAL; 2299 return -EINVAL;
2292 } 2300 }