drm/amd/display: fix potential integer overflow when shifting 32 bit variable bl_pwm
PATCH 1/1 drm/amd/display: fix potential integer overflow when shifting 32 bit variable bl_pwm
From: Colin Ian King <[email protected]>
The 32 bit unsigned integer bl_pwm is being shifted using 32 bit arithmetic and then being assigned to a 64 bit unsigned integer. There is a potential for a 32 bit overflow so cast bl_pwm to enforce a 64 bit shift operation to avoid this.
Addresses-Coverity: ("unintentional integer overflow")
--- drivers/gpu/drm/amd/display/dc/dce/dce_panel_cntl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dce/dce_panel_cntl.c +1 -1
@@ -76,7 +76,7 @@ static unsigned int dce_get_16_bit_backlight_from_pwm(struct panel_cntl *panel_celse bl_pwm &=0xFFFF ; - current_backlight = bl_pwm << (1 + bl_int_count); + current_backlight = (uint64_t )bl_pwm << (1 + bl_int_count);if (bl_period =0 ) bl_period =0xFFFF ;
Signature · 1 line
2.27.0
Alex Deucher
AppliedQuoted 11 lines · Colin King
From: Colin Ian King <[email protected]>
The 32 bit unsigned integer
bl_pwmis being shifted using 32 bit arithmetic and then being assigned to a 64 bit unsigned integer. There is a potential for a 32 bit overflow so castbl_pwmto enforce a 64 bit shift operation to avoid this.Addresses-Coverity: ("unintentional integer overflow")
Fixes 3ba01817365c ("drm/amd/display: Move panel_cntl specific register from abm to panel_cntl.")Signed-off-by Colin Ian King <[email protected]>
Applied. Thanks!
Alex
Quoted 24 lines
--- drivers/gpu/drm/amd/display/dc/dce/dce_panel_cntl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/display/dc/dce/dce_panel_cntl.c +1
-2@@ -76,7 +76,7 @@ static unsigned int dce_get_16_bit_backlight_from_pwm(struct panel_cntl *panel_celse bl_pwm &=0xFFFF ; - current_backlight = bl_pwm << (1 + bl_int_count); + current_backlight = (uint64_t )bl_pwm << (1 + bl_int_count);if (bl_period =0 ) bl_period =0xFFFF ; --2.27.0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel