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] [day] [month] [year] [list]
Message-ID: <f552799ea07049829e68ea63668cbcc8@AcuMS.aculab.com>
Date:   Fri, 11 Feb 2022 12:23:32 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Kalle Valo' <kvalo@...nel.org>, Qing Wang <wangqing@...o.com>
CC:     Maya Erez <merez@...eaurora.org>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        "linux-wireless@...r.kernel.org" <linux-wireless@...r.kernel.org>,
        "wil6210@....qualcomm.com" <wil6210@....qualcomm.com>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] net: wireless: ath: use div64_u64() instead of do_div()

From: Kalle Valo
> Sent: 10 February 2022 12:16
> 
> Qing Wang <wangqing@...o.com> writes:
> 
> > 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/net/wireless/ath/wil6210/debugfs.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c b/drivers/net/wireless/ath/wil6210/debugfs.c
> > index 4c944e5..2cee9dd
> > --- a/drivers/net/wireless/ath/wil6210/debugfs.c
> > +++ b/drivers/net/wireless/ath/wil6210/debugfs.c
> > @@ -1766,7 +1766,7 @@ __acquires(&p->tid_rx_lock) __releases(&p->tid_rx_lock)
> >  			seq_puts(s, "\n");
> >  			if (!num_packets)
> >  				continue;
> > -			do_div(tx_latency_avg, num_packets);
> > +			div64_u64(tx_latency_avg, num_packets);
> 
> As you have been pointed out in your other patches, do_div() and
> div64_u64() work differently.

And how long does it take for num_packets to exceed 2^32.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ