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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 24 Dec 2022 22:36:55 +0300
From:   Dan Carpenter <error27@...il.com>
To:     Andy Shevchenko <andy.shevchenko@...il.com>
Cc:     oe-kbuild@...ts.linux.dev, Qingtao Cao <qingtao.cao.au@...il.com>,
        lkp@...el.com, oe-kbuild-all@...ts.linux.dev,
        linux-kernel@...r.kernel.org, Bartosz Golaszewski <brgl@...ev.pl>
Subject: Re: drivers/gpio/gpio-exar.c:52 exar_offset_to_sel_addr() warn:
 replace divide condition 'pin / 8' with 'pin >= 8'

On Sat, Dec 24, 2022 at 10:30:39PM +0300, Dan Carpenter wrote:
> On Sat, Dec 24, 2022 at 05:19:27PM +0100, Andy Shevchenko wrote:
> > 
> > 
> > Lähetetty iPhonesta
> > 
> > > Dan Carpenter <error27@...il.com> kirjoitti 23.12.2022 kello 11.54:
> > > 
> > > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > > head:   f9ff5644bcc04221bae56f922122f2b7f5d24d62
> > > commit: 5134272f9f3f71d4e1f3aa15cb09321af49b3646 gpio: exar: access MPIO registers on cascaded chips
> > > config: ia64-randconfig-m031-20221218
> > > compiler: ia64-linux-gcc (GCC) 12.1.0
> > > 
> > > If you fix the issue, kindly add following tag where applicable
> > > | Reported-by: kernel test robot <lkp@...el.com>
> > > | Reported-by: Dan Carpenter <error27@...il.com>
> > > 
> > > smatch warnings:
> > > drivers/gpio/gpio-exar.c:52 exar_offset_to_sel_addr() warn: replace divide condition 'pin / 8' with 'pin >= 8'
> > > drivers/gpio/gpio-exar.c:62 exar_offset_to_lvl_addr() warn: replace divide condition 'pin / 8' with 'pin >= 8'
> > > 
> > 
> > 
> > 
> > I don’t think this is a good advice. If we want to limit that, we need
> > to check also upper limit. But. The GPIO framework does that. So,
> > changing / to >= is bogus.
> 
> 
> How is checking pin / 8 not mathematically equivalent to pin >= 8?
> 
> I don't understand this code at all.  The divide is inscrutable  Is it
> storing something in in the lower 3 bits and something in bit 4?  In
> that case it might be nicer to just check (pin & BIT(4)).
> 

Or a macro which does:

#define GET_UPPER_BIT_THING(pin) ((pin >> 8) & 0xMASK)

regards,
dan carpenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ