Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/arm: fix unintentional integer overflow on left shift

Shifting the integer value 1 is evaluated using 32-bit arithmetic
and then used in an expression that expects a long value leads to
a potential integer overflow. Fix this by using the BIT macro to
perform the shift to avoid the overflow.

Addresses-Coverity: ("Unintentional integer overflow")
Fixes: ad49f8602fe8 ("drm/arm: Add support for Mali Display Processors")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Liviu Dudau <liviu.dudau@arm.com>
Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200618100400.11464-1-colin.king@canonical.com

authored by

Colin Ian King and committed by
Liviu Dudau
5f368dde 79ce0580

+1 -1
+1 -1
drivers/gpu/drm/arm/malidp_planes.c
··· 928 928 const struct malidp_hw_regmap *map = &malidp->dev->hw->map; 929 929 struct malidp_plane *plane = NULL; 930 930 enum drm_plane_type plane_type; 931 - unsigned long crtcs = 1 << drm->mode_config.num_crtc; 931 + unsigned long crtcs = BIT(drm->mode_config.num_crtc); 932 932 unsigned long flags = DRM_MODE_ROTATE_0 | DRM_MODE_ROTATE_90 | DRM_MODE_ROTATE_180 | 933 933 DRM_MODE_ROTATE_270 | DRM_MODE_REFLECT_X | DRM_MODE_REFLECT_Y; 934 934 unsigned int blend_caps = BIT(DRM_MODE_BLEND_PIXEL_NONE) |