Skip to content

Commit ce0cb93

Browse files
Colin Ian Kingmmind
authored andcommitted
drm/rockchip: cdn-dp: fix sign extension on an int multiply for a u64 result
The variable bit_per_pix is a u8 and is promoted in the multiplication to an int type and then sign extended to a u64. If the result of the int multiplication is greater than 0x7fffffff then the upper 32 bits will be set to 1 as a result of the sign extension. Avoid this by casting tu_size_reg to u64 to avoid sign extension and also a potential overflow. Fixes: 1a0f7ed ("drm/rockchip: cdn-dp: add cdn DP support for rk3399") Signed-off-by: Colin Ian King <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Signed-off-by: Heiko Stuebner <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 3dfa159 commit ce0cb93

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/gpu/drm/rockchip/cdn-dp-reg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ int cdn_dp_config_video(struct cdn_dp_device *dp)
658658
*/
659659
do {
660660
tu_size_reg += 2;
661-
symbol = tu_size_reg * mode->clock * bit_per_pix;
661+
symbol = (u64)tu_size_reg * mode->clock * bit_per_pix;
662662
do_div(symbol, dp->max_lanes * link_rate * 8);
663663
rem = do_div(symbol, 1000);
664664
if (tu_size_reg > 64) {

0 commit comments

Comments
 (0)