Skip to contentSkip to conversation

drm/tegra : Avoid potential integer overflow of 32 bit int

PATCH Applied Nur Hussein 2 participants 2 messages Apr 5, 2023 – Apr 6, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/tegra : Avoid potential integer overflow of 32 bit int

In tegra_sor_compute_config(), the 32-bit value mode->clock is multiplied by 1000, and assigned to the u64 variable pclk. We can avoid a potential 32-bit integer overflow by casting mode->clock to u64 before we do the arithmetic and assignment.

---
 drivers/gpu/drm/tegra/sor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/tegra/sor.c +1 -1
index cd25f409979c..8d910695775c 100644
@@ -1153,7 +1153,7 @@ static int tegra_sor_compute_config(struct tegra_sor *sor,
 				    struct drm_dp_link *link)
 {
 	const u64 f = 100000, link_rate = link->rate * 1000;
-	const u64 pclk = mode->clock * 1000;
+	const u64 pclk = (u64)mode->clock * 1000;
 	u64 input, output, watermark, num;
 	struct tegra_sor_params params;
 	u32 num_syms_per_line;
Signature · 1 line
2.34.1
#1 lore raw

From: Thierry Reding <[email protected]>

Quoted 6 lines · Nur Hussein

In tegra_sor_compute_config(), the 32-bit value mode->clock is multiplied by 1000, and assigned to the u64 variable pclk. We can avoid a potential 32-bit integer overflow by casting mode->clock to u64 before we do the arithmetic and assignment.

Applied, thanks!

[1/1] drm/tegra : Avoid potential integer overflow of 32 bit int
(no commit info)

Best regards,

Signature · 1 line
Thierry Reding <[email protected]>