]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/amd/display: fix potential integer overflow when shifting 32 bit variable bl_pwm
authorColin Ian King <colin.king@canonical.com>
Tue, 18 Aug 2020 12:09:14 +0000 (13:09 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Oct 2020 09:07:30 +0000 (10:07 +0100)
[ Upstream commit 1d5503331b12a76266049289747dfd94f1643fde ]

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")
Fixes: 3ba01817365c ("drm/amd/display: Move panel_cntl specific register from abm to panel_cntl.")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/amd/display/dc/dce/dce_panel_cntl.c

index ebff9b1e312e5f88a593dbbd8386c33d8f3e0fed..124c081a0f2cadec848e96661bb488da2d8ad159 100644 (file)
@@ -75,7 +75,7 @@ static unsigned int calculate_16_bit_backlight_from_pwm(struct dce_panel_cntl *d
        else
                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;