|
@@ -65,12 +65,13 @@ int drm_mode_create_dumb_ioctl(struct drm_device *dev,
|
|
|
return -EINVAL;
|
|
|
|
|
|
/* overflow checks for 32bit size calculations */
|
|
|
- /* NOTE: DIV_ROUND_UP() can overflow */
|
|
|
+ if (args->bpp > U32_MAX - 8)
|
|
|
+ return -EINVAL;
|
|
|
cpp = DIV_ROUND_UP(args->bpp, 8);
|
|
|
- if (!cpp || cpp > 0xffffffffU / args->width)
|
|
|
+ if (cpp > U32_MAX / args->width)
|
|
|
return -EINVAL;
|
|
|
stride = cpp * args->width;
|
|
|
- if (args->height > 0xffffffffU / stride)
|
|
|
+ if (args->height > U32_MAX / stride)
|
|
|
return -EINVAL;
|
|
|
|
|
|
/* test for wrap-around */
|