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: <OS0PR01MB59221A1F4614F30669F3448D86EEA@OS0PR01MB5922.jpnprd01.prod.outlook.com>
Date:   Thu, 7 Sep 2023 06:42:38 +0000
From:   Biju Das <biju.das.jz@...renesas.com>
To:     Wolfram Sang <wsa+renesas@...g-engineering.com>,
        "linux-renesas-soc@...r.kernel.org" 
        <linux-renesas-soc@...r.kernel.org>
CC:     Chris Brandt <Chris.Brandt@...esas.com>,
        Andi Shyti <andi.shyti@...nel.org>,
        "linux-i2c@...r.kernel.org" <linux-i2c@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH 5/5] i2c: riic: avoid potential division by zero

Hi Wolfram Sang,

> Subject: [PATCH 5/5] i2c: riic: avoid potential division by zero
> 
> Value comes from DT, so it could be 0. Unlikely, but could be.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@...g-engineering.com>
> ---
>  drivers/i2c/busses/i2c-riic.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c
> index f0ee8871d5ae..e43ff483c56e 100644
> --- a/drivers/i2c/busses/i2c-riic.c
> +++ b/drivers/i2c/busses/i2c-riic.c
> @@ -313,7 +313,7 @@ static int riic_init_hw(struct riic_dev *riic, struct
> i2c_timings *t)
>  	 * frequency with only 62 clock ticks max (31 high, 31 low).
>  	 * Aim for a duty of 60% LOW, 40% HIGH.
>  	 */
> -	total_ticks = DIV_ROUND_UP(rate, t->bus_freq_hz);
> +	total_ticks = DIV_ROUND_UP(rate, t->bus_freq_hz ?: 1);

Not sure clamping function min_t/min(t->bus_freq_hz, 1)
Or ternary condition is good in this case for avoiding potential division by 0?

Cheers,
Biju

> 
>  	for (cks = 0; cks < 7; cks++) {
>  		/*
> --
> 2.35.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ