2022-06-09 19:24:02

by Saud Farooqui

[permalink] [raw]
Subject: [PATCH] drm/vc4: hdmi: Fixed possible integer overflow

Multiplying ints and saving it in unsigned long long
could lead to integer overflow before being type casted to
unsigned long long.

Addresses-Coverity: 1505113: Unintentional integer overflow.

Signed-off-by: Saud Farooqui <[email protected]>
---
drivers/gpu/drm/vc4/vc4_hdmi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
index 823d812f4982..ce9d16666d91 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -1481,7 +1481,7 @@ vc4_hdmi_encoder_compute_mode_clock(const struct drm_display_mode *mode,
unsigned int bpc,
enum vc4_hdmi_output_format fmt)
{
- unsigned long long clock = mode->clock * 1000;
+ unsigned long long clock = mode->clock * 1000ULL;

if (mode->flags & DRM_MODE_FLAG_DBLCLK)
clock = clock * 2;
--
2.25.1


2022-06-22 08:15:35

by Maxime Ripard

[permalink] [raw]
Subject: Re: (subset) [PATCH] drm/vc4: hdmi: Fixed possible integer overflow

On Thu, 9 Jun 2022 23:50:31 +0500, Saud Farooqui wrote:
> Multiplying ints and saving it in unsigned long long
> could lead to integer overflow before being type casted to
> unsigned long long.
>
> Addresses-Coverity: 1505113: Unintentional integer overflow.
>
>
> [...]

Applied to drm/drm-misc (drm-misc-fixes).

Thanks!
Maxime