vpos (int) field multiplied by crtc_htotal (u16) may cause implicit promotion of the latter and overflow the result causing undefined behavior.
Cast the u16 operand to (s32) type to avoid that. Signed-off-by: Krzysztof Karas <[email protected]> --- v4: * use s32 cast instead of int; drivers/gpu/drm/drm_vblank.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c index 32d013c5c8fc..e25dcaa6cad4 100644 --- a/drivers/gpu/drm/drm_vblank.c +++ b/drivers/gpu/drm/drm_vblank.c @@ -791,7 +791,7 @@ drm_crtc_vblank_helper_get_vblank_timestamp_internal( * since start of scanout at first display scanline. delta_ns * can be negative if start of scanout hasn't happened yet. */ - delta_ns = div_s64(1000000LL * (vpos * mode->crtc_htotal + hpos), + delta_ns = div_s64(1000000LL * (vpos * (s32)mode->crtc_htotal + hpos), mode->crtc_clock); /* Subtract time delta from raw timestamp to get final -- 2.34.1
