linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/komeda: Fix potential integer overflow in komeda_crtc_update_clock_ratio
@ 2019-08-12  0:08 Gustavo A. R. Silva
  2019-08-12 10:18 ` james qian wang (Arm Technology China)
  0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2019-08-12  0:08 UTC (permalink / raw)
  To: James (Qian) Wang, Liviu Dudau, Brian Starkey, David Airlie,
	Daniel Vetter
  Cc: dri-devel, linux-kernel, 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 <gustavo@embeddedor.com>
---
 drivers/gpu/drm/arm/display/komeda/komeda_crtc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
index fa9a4593bb37..624d257da20f 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
@@ -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);
-- 
2.22.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: drm/komeda: Fix potential integer overflow in komeda_crtc_update_clock_ratio
  2019-08-12  0:08 [PATCH] drm/komeda: Fix potential integer overflow in komeda_crtc_update_clock_ratio Gustavo A. R. Silva
@ 2019-08-12 10:18 ` james qian wang (Arm Technology China)
  0 siblings, 0 replies; 2+ messages in thread
From: james qian wang (Arm Technology China) @ 2019-08-12 10:18 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Liviu Dudau, Brian Starkey, David Airlie, Daniel Vetter,
	linux-kernel, dri-devel, nd

On Sun, Aug 11, 2019 at 07:08:01PM -0500, Gustavo A. R. Silva wrote:
> 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 <gustavo@embeddedor.com>
> ---
>  drivers/gpu/drm/arm/display/komeda/komeda_crtc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> index fa9a4593bb37..624d257da20f 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> @@ -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.

Reviewed-by: James Qian Wang (Arm Technology China) <james.qian.wang@arm.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-08-12 10:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-12  0:08 [PATCH] drm/komeda: Fix potential integer overflow in komeda_crtc_update_clock_ratio Gustavo A. R. Silva
2019-08-12 10:18 ` james qian wang (Arm Technology China)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).