drm/komeda: Fix potential integer overflow in komeda_crtc_update_clock_ratio
Subsystems (4)
PATCH 1/1 drm/komeda: Fix potential integer overflow in komeda_crtc_update_clock_ratio
Add suffix ULL to constant 1000 in order to avoid a potential integer overflow and give the compiler complete information about the proper arithmetic to use. Notice that this constant is being used in a context that expects an expression of type u64, but it's currently evaluated using 32-bit arithmetic.
Addresses-Coverity-ID: 1485796 ("Unintentional integer overflow")
--- drivers/gpu/drm/arm/display/komeda/komeda_crtc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/arm/display/komeda/komeda_crtc.c +1 -1
@@ -27,7 +27,7 @@ static void komeda_crtc_update_clock_ratio(struct komeda_crtc_state *kcrtc_st)return ; } - pxlclk = kcrtc_st->base.adjusted_mode.crtc_clock *1000 ; + pxlclk = kcrtc_st->base.adjusted_mode.crtc_clock *1000ULL ; aclk =komeda_crtc_get_aclk (kcrtc_st); kcrtc_st->clock_ratio =div64_u64 (aclk <<32 , pxlclk);
Signature · 1 line
2.22.0
Quoted 18 lines · Gustavo A. R. Silva
Add suffix ULL to constant 1000 in order to avoid a potential integer overflow and give the compiler complete information about the proper arithmetic to use. Notice that this constant is being used in a context that expects an expression of type u64, but it's currently evaluated using 32-bit arithmetic.
Addresses-Coverity-ID: 1485796 ("Unintentional integer overflow")
Fixes ed22c6d9304d ("drm/komeda: Use drm_display_mode "crtc_" prefixed hardware timings")Signed-off-by Gustavo A. R. Silva <[email protected]>--- drivers/gpu/drm/arm/display/komeda/komeda_crtc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/arm/display/komeda/komeda_crtc.c +0
-0
drivers/gpu/drm/arm/display/komeda/komeda_crtc.c static void komeda_crtc_update_clock_ratio(struct komeda_crtc_state *kcrtc_st) · line 33
Quoted 8 lines
drivers/gpu/drm/arm/display/komeda/komeda_crtc.c +1
-1@@ -27,7 +27,7 @@ static void komeda_crtc_update_clock_ratio(struct komeda_crtc_state *kcrtc_st)return ; } - pxlclk = kcrtc_st->base.adjusted_mode.crtc_clock *1000 ; + pxlclk = kcrtc_st->base.adjusted_mode.crtc_clock *1000ULL ; aclk =komeda_crtc_get_aclk (kcrtc_st); kcrtc_st->clock_ratio =div64_u64 (aclk <<32 , pxlclk);
Thank you for the patch.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel