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: <20191006095133.24fb89be@archlinux>
Date:   Sun, 6 Oct 2019 09:51:33 +0100
From:   Jonathan Cameron <jic23@...nel.org>
To:     Dan Carpenter <dan.carpenter@...cle.com>
Cc:     "Ardelean, Alexandru" <alexandru.Ardelean@...log.com>,
        "lars@...afoo.de" <lars@...afoo.de>,
        "kernel-janitors@...r.kernel.org" <kernel-janitors@...r.kernel.org>,
        "Popa, Stefan Serban" <StefanSerban.Popa@...log.com>,
        "linux-iio@...r.kernel.org" <linux-iio@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "Hennerich, Michael" <Michael.Hennerich@...log.com>,
        "pmeerw@...erw.net" <pmeerw@...erw.net>,
        "knaack.h@....de" <knaack.h@....de>
Subject: Re: [PATCH] iio: imu: adis16480: clean up a condition

On Thu, 26 Sep 2019 14:36:30 +0300
Dan Carpenter <dan.carpenter@...cle.com> wrote:

> On Thu, Sep 26, 2019 at 11:06:39AM +0000, Ardelean, Alexandru wrote:
> > On Thu, 2019-09-26 at 11:10 +0300, Dan Carpenter wrote:  
> > > [External]
> > > 
> > > The "t" variable is unsigned so it can't be less than zero.  We really
> > > are just trying to prevent divide by zero bugs so just checking against
> > > zero is sufficient.

I'm not sure that true.  It if were signed we'd be detecting that the
input from userspace was negative.  That is clearly garbage for a frequency
control..  I'll hazard a guess that it was intended to catch that
as well as the divide by 0 case. 

This would be clearer if we first checked that val and val2 are both not
negative, then did the zero test on t.

If people agree, anyone want to spin a patch to do that?

Thanks,

Jonathan

> > > 
> > > Signed-off-by: Dan Carpenter <dan.carpenter@...cle.com>
> > > ---
> > >  drivers/iio/imu/adis16480.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
> > > index b99d73887c9f..e144e567675d 100644
> > > --- a/drivers/iio/imu/adis16480.c
> > > +++ b/drivers/iio/imu/adis16480.c
> > > @@ -318,7 +318,7 @@ static int adis16480_set_freq(struct iio_dev
> > > *indio_dev, int val, int val2)
> > >  	unsigned int t, reg;  
> > 
> > I would just change the type of "t" to "int".
> > Especially, since "val" & "val2" are "int".
> >   
> 
> Yeah, but negatives or high values are basically fine.  We only care
> zero.
> 
> regards,
> dan carpenter
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ