Re: [PATCH] iio: imu: bno055: uninitialized variable bug in bno055_trigger_handler()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 15 Oct 2022 17:33:59 +0100
Jonathan Cameron <jic23@xxxxxxxxxx> wrote:

> On Fri, 14 Oct 2022 12:39:52 +0300
> Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote:
> 
> > This bug is basically harmless, although it will trigger a runtime warning
> > if you use KMSan.  On the first iteration through the loop, the
> > "best_delta" variable is uninitialized so re-order the condition to
> > prevent reading uninitialized memory.
> > 
> > Fixes: 4aefe1c2bd0c ("iio: imu: add Bosch Sensortec BNO055 core driver")
> > Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>  
> 
> You reported this a while back along with a second issue (false positive)
> with hwval.
> 
> I posted a patch fixing both 
> https://lore.kernel.org/linux-iio/20221002145324.3776484-1-jic23@xxxxxxxxxx/
> 
> I don't really care which patch goes in, but curious to reasoning to not also
> deal with the hwval warning here?
> 
Meh. Rather than not applying either patch, I'll pick this one up.  We can
deal with the hwval warning at a later date if necessary.

Applied to the fixes-togreg branch of iio.git.

Jonathan

> Jonathan
> 
> > ---
> >  drivers/iio/imu/bno055/bno055.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/iio/imu/bno055/bno055.c b/drivers/iio/imu/bno055/bno055.c
> > index 307557a609e3..52744dd98e65 100644
> > --- a/drivers/iio/imu/bno055/bno055.c
> > +++ b/drivers/iio/imu/bno055/bno055.c
> > @@ -632,7 +632,7 @@ static int bno055_set_regmask(struct bno055_priv *priv, int val, int val2,
> >  			return -EINVAL;
> >  		}
> >  		delta = abs(tbl_val - req_val);
> > -		if (delta < best_delta || first) {
> > +		if (first || delta < best_delta) {
> >  			best_delta = delta;
> >  			hwval = i;
> >  			first = false;  
> 




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux