]> Git Repo - linux.git/commitdiff
iio: imu: bno055: uninitialized variable bug in bno055_trigger_handler()
authorDan Carpenter <[email protected]>
Fri, 14 Oct 2022 09:39:52 +0000 (12:39 +0300)
committerJonathan Cameron <[email protected]>
Tue, 1 Nov 2022 08:48:13 +0000 (08:48 +0000)
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]>
Acked-by: Nuno Sá <[email protected]>
Link: https://lore.kernel.org/r/Y0kuaO9PQkSQja+A@kili
Signed-off-by: Jonathan Cameron <[email protected]>
drivers/iio/imu/bno055/bno055.c

index 307557a609e3f0b099be87d5f38f53e994b07e45..52744dd98e65b41630489affdc44ea65e82b192b 100644 (file)
@@ -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;
This page took 0.061068 seconds and 4 git commands to generate.