Skip to contentSkip to conversation

drm/amd/display: Fix potential integer overflow

PATCH Applied Gustavo A. R. Silva 2 participants 2 messages Feb 10, 2021 – Feb 15, 2021

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

PATCH 1/1 drm/amd/display: Fix potential integer overflow

Fix potential integer overflow by casting actual_calculated_clock_100hz to u64, in order to give the compiler complete information about the proper arithmetic to use.

Notice that such variable is used in a context that expects an expression of type u64 (64 bits, unsigned) and the following expression is currently being evaluated using 32-bit arithmetic:

actual_calculated_clock_100hz * post_divider

Fixes 7a03fdf628af ("drm/amd/display: fix 64bit division issue on 32bit OS")

Addresses-Coverity-ID: 1501691 ("Unintentional integer overflow")

---
 drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c +1 -1
index bc942725b9d8..dec58b3c42e4 100644
@@ -240,7 +240,7 @@ static bool calc_fb_divider_checking_tolerance(
 		pll_settings->calculated_pix_clk_100hz =
 			actual_calculated_clock_100hz;
 		pll_settings->vco_freq =
-			div_u64(actual_calculated_clock_100hz * post_divider, 10);
+			div_u64((u64)actual_calculated_clock_100hz * post_divider, 10);
 		return true;
 	}
 	return false;
Signature · 6 lines
2.27.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Applied
#1 lore raw
Quoted 9 lines · Gustavo A. R. Silva

Fix potential integer overflow by casting actual_calculated_clock_100hz to u64, in order to give the compiler complete information about the proper arithmetic to use.

Notice that such variable is used in a context that expects an expression of type u64 (64 bits, unsigned) and the following expression is currently being evaluated using 32-bit arithmetic:

Quoted 5 lines

actual_calculated_clock_100hz * post_divider

Fixes 7a03fdf628af ("drm/amd/display: fix 64bit division issue on 32bit OS")

Addresses-Coverity-ID: 1501691 ("Unintentional integer overflow")

Applied. Thanks!

Alex

Quoted 20 lines
---
 drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c +1 -2
index bc942725b9d8..dec58b3c42e4 100644
@@ -240,7 +240,7 @@ static bool calc_fb_divider_checking_tolerance(
                pll_settings->calculated_pix_clk_100hz =
                        actual_calculated_clock_100hz;
                pll_settings->vco_freq =
-                       div_u64(actual_calculated_clock_100hz * post_divider, 10);
+                       div_u64((u64)actual_calculated_clock_100hz * post_divider, 10);
                return true;
        }
        return false;
--

2.27.0

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel