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]
Message-ID: <20220209152609.gqeivcehkuzgz3sk@pengutronix.de>
Date:   Wed, 9 Feb 2022 16:26:09 +0100
From:   Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
To:     Qing Wang <wangqing@...o.com>
Cc:     Thierry Reding <thierry.reding@...il.com>,
        Lee Jones <lee.jones@...aro.org>, linux-pwm@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] pwm: use div64_u64() instead of do_div()

Hello,

On Wed, Feb 09, 2022 at 12:39:58AM -0800, Qing Wang wrote:
> From: Wang Qing <wangqing@...o.com>
> 
> do_div() does a 64-by-32 division.
> When the divisor is u64, do_div() truncates it to 32 bits, this means it
> can test non-zero and be truncated to zero for division.
> 
> fix do_div.cocci warning:
> do_div() does a 64-by-32 division, please consider using div64_u64 instead.
> 
> Signed-off-by: Wang Qing <wangqing@...o.com>
> ---
>  drivers/pwm/pwm-berlin.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pwm/pwm-berlin.c b/drivers/pwm/pwm-berlin.c
> index e157273..15b10cb3
> --- a/drivers/pwm/pwm-berlin.c
> +++ b/drivers/pwm/pwm-berlin.c
> @@ -109,7 +109,7 @@ static int berlin_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
>  
>  	period = cycles;
>  	cycles *= duty_ns;
> -	do_div(cycles, period_ns);
> +	div64_u64(cycles, period_ns);

This is wrong, div64_u64() has a different calling convention than do_div().

The issue however is real. Please add 

Fixes: 30dffb42fcd4 ("pwm: berlin: Implement .apply() callback")

to your v2.

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