Thread (4 messages) 4 messages, 3 authors, 2025-05-05

Re: [PATCH] drm/meson: Cast mode->clock to unsigned long long

From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Date: 2025-05-04 21:06:17
Also in: dri-devel, linux-amlogic, lkml

On Tue, Apr 29, 2025 at 11:00 PM Christophe JAILLET
[off-list ref] wrote:
Le 29/04/2025 à 21:07, I Hsin Cheng a écrit :
quoted
Coverity scan reported the usage of "mode->clock * 1000" may lead to
integer overflow. Cast the type of "mode->clock" to "unsigned long long"
when utilizing it to avoid potential integer overflow issue.

Link: https://scan5.scan.coverity.com/#/project-view/10074/10063?selectedIssue=1646759
Signed-off-by: I Hsin Cheng <redacted>
---
  drivers/gpu/drm/meson/meson_encoder_hdmi.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/meson/meson_encoder_hdmi.c b/drivers/gpu/drm/meson/meson_encoder_hdmi.c
index 7752d8ac85f0..fe3d3ff7c432 100644
--- a/drivers/gpu/drm/meson/meson_encoder_hdmi.c
+++ b/drivers/gpu/drm/meson/meson_encoder_hdmi.c
@@ -75,7 +75,7 @@ static void meson_encoder_hdmi_set_vclk(struct meson_encoder_hdmi *encoder_hdmi,
      unsigned long long venc_freq;
      unsigned long long hdmi_freq;

-     vclk_freq = mode->clock * 1000;
+     vclk_freq = (unsigned long long) mode->clock * 1000;
Hi,

maybe, using 1000ULL instead would do the same, but would be less verbose?
Agreed, that would make the code more similar to drm_hdmi_compute_mode_clock().
The goal is to switch to drm_hdmi_compute_mode_clock() mid-term anyways.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help