iio: imu: bno055: uninitialized variable bug in bno055_trigger_handler()
Subsystems (2)
PATCH 1/1 iio: imu: bno055: uninitialized variable bug in bno055_trigger_handler()
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.
--- drivers/iio/imu/bno055/bno055.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/imu/bno055/bno055.c +1 -1
@@ -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;
Signature · 1 line
2.35.1
Quoted 14 lines
-----Original Message-----
From: Dan Carpenter <[email protected]>
Sent: Friday, October 14, 2022 11:40 AM
To: Jonathan Cameron <[email protected]>; Andrea Merello <[email protected]>
Cc: Lars-Peter Clausen <[email protected]>; [email protected]; [email protected]
Subject: [PATCH] iio: imu: bno055: uninitialized variable bug inbno055_trigger_handler()[External]
Quoted 8 lines
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 <[email protected]>---
Jonathan Cameron
maintainerQuoted 7 lines · On Fri, 14 Oct 2022 12:39:52 +0300 Dan Carpenter <[email protected]>…
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 <[email protected]>
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/[email protected]/
I don't really care which patch goes in, but curious to reasoning to not also deal with the hwval warning here?
Jonathan
Quoted 17 lines
--- drivers/iio/imu/bno055/bno055.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iio/imu/bno055/bno055.c +1
-1@@ -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;
Quoted 11 lines · On Sat, 15 Oct 2022 17:33:59 +0100 Jonathan Cameron <[email protected]> wrote:
Quoted 7 lines · On Fri, 14 Oct 2022 12:39:52 +0300 Dan Carpenter <[email protected]>…
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 <[email protected]>
Quoted 9 lines
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/[email protected]/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
Quoted 20 lines
Jonathan
Quoted 17 lines
--- drivers/iio/imu/bno055/bno055.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iio/imu/bno055/bno055.c +1
-1@@ -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;
Quoted 17 lines · Jonathan Cameron
Quoted 14 lines · On Sat, 15 Oct 2022 17:33:59 +0100 Jonathan Cameron <[email protected]> wrote:
Quoted 7 lines · On Fri, 14 Oct 2022 12:39:52 +0300 Dan Carpenter <[email protected]>…
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 <[email protected]>You reported this a while back along with a second issue (false positive) with hwval.
Quoted 9 lines
Quoted 6 lines
I posted a patch fixing both
https://lore.kernel.org/linux-iio/[email protected]/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.
Sorry, I am behind in my email.
There was a couple weeks in between sending the bug report and the patch so I forgot about it. Also I send those bug reports from a different system so I don't check that as part of the QC process. I'm moving to checking vger instead of grepping my outbox but I haven't automated that yet.
I don't get a "hwval" warning on my system so using the cross function DB must have silenced the false positive.
regards,
dan carpenter