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:   Wed, 17 Nov 2021 12:24:00 +0100
From:   Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
To:     cgel.zte@...il.com
Cc:     thierry.reding@...il.com, lee.jones@...aro.org,
        nicolas.ferre@...rochip.com, alexandre.belloni@...tlin.com,
        ludovic.desroches@...rochip.com, linux-pwm@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
        Changcheng Deng <deng.changcheng@....com.cn>,
        Zeal Robot <zealci@....com.cn>
Subject: Re: [PATCH] pwm: Use div64_ul instead of do_div

Hello,

On Wed, Nov 17, 2021 at 02:04:26AM +0000, cgel.zte@...il.com wrote:
> From: Changcheng Deng <deng.changcheng@....com.cn>
> 
> do_div() does a 64-by-32 division. If the divisor is unsigned long, using
> div64_ul can avoid truncation to 32-bit.

After some research I understood your commit log. I'd write:

	do_div() does a 64-by-32 division. Here the divsor is an
	unsigned long which on some platforms is 64 bit wide. So use
	div64_ul instead of do_div to avoid a possible truncation.

The priority of this patch seems to be low, as the device seems to exist
only on (32bit) arm.

> diff --git a/drivers/pwm/pwm-atmel-hlcdc.c b/drivers/pwm/pwm-atmel-hlcdc.c
> index a43b2babc809..1ae3d73b9832 100644
> --- a/drivers/pwm/pwm-atmel-hlcdc.c
> +++ b/drivers/pwm/pwm-atmel-hlcdc.c
> @@ -60,7 +60,7 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm,
>  				return -EINVAL;
>  
>  			clk_period_ns = (u64)NSEC_PER_SEC * 256;
> -			do_div(clk_period_ns, clk_freq);
> +			div64_ul(clk_period_ns, clk_freq);

This must be

	clk_period_ns = div64_ul(clk_period_ns, clk_freq);

as div64_ul has a different calling convention than do_div. Same problem
in the next hunk.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ