lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 16 May 2023 19:06:58 +0200
From:   Thomas Zimmermann <tzimmermann@...e.de>
To:     Sui Jingfeng <suijingfeng@...ngson.cn>,
        suijingfeng <15330273260@....cn>
Cc:     Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
        Maxime Ripard <mripard@...nel.org>,
        David Airlie <airlied@...il.com>,
        Daniel Vetter <daniel@...ll.ch>,
        dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] drm/drm_vblank.c: avoid unsigned int to signed int cast



Am 16.05.23 um 18:59 schrieb Sui Jingfeng:
> Both mode->crtc_htotal and mode->crtc_vtotal are u16 type,
> mode->crtc_htotal * mode->crtc_vtotal will results a unsigned type.
> Using a u32 is enough to store the result, but considering that the
> result will be casted to u64 soon after. We use a u64 type directly.
> 
> So there no need to cast it to signed type and cast back then.
> 
> Signed-off-by: Sui Jingfeng <suijingfeng@...ngson.cn>
> Cc: Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>
> Cc: Maxime Ripard <mripard@...nel.org>
> Cc: Thomas Zimmermann <tzimmermann@...e.de>
> Cc: David Airlie <airlied@...il.com>
> Cc: Daniel Vetter <daniel@...ll.ch>
> Cc: dri-devel@...ts.freedesktop.org
> Cc: linux-kernel@...r.kernel.org

Reviewed-by: Thomas Zimmermann <tzimmermann@...e.de>

> ---
>   drivers/gpu/drm/drm_vblank.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
> index 877e2067534f..d99c404b181b 100644
> --- a/drivers/gpu/drm/drm_vblank.c
> +++ b/drivers/gpu/drm/drm_vblank.c
> @@ -622,7 +622,7 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc,
>   
>   	/* Valid dotclock? */
>   	if (dotclock > 0) {
> -		int frame_size = mode->crtc_htotal * mode->crtc_vtotal;
> +		u64 frame_size = mode->crtc_htotal * mode->crtc_vtotal;
>   
>   		/*
>   		 * Convert scanline length in pixels and video
> @@ -630,7 +630,7 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc,
>   		 * in nanoseconds:
>   		 */
>   		linedur_ns  = div_u64((u64) mode->crtc_htotal * 1000000, dotclock);
> -		framedur_ns = div_u64((u64) frame_size * 1000000, dotclock);
> +		framedur_ns = div_u64(frame_size * 1000000, dotclock);
>   
>   		/*
>   		 * Fields of interlaced scanout modes are only half a frame duration.

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)

Download attachment "OpenPGP_signature" of type "application/pgp-signature" (841 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ