Skip to content

Commit dd4753f

Browse files
Dan Carpenterjic23
authored andcommitted
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. Fixes: 4aefe1c ("iio: imu: add Bosch Sensortec BNO055 core driver") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Nuno Sá <nuno.sa@analog.com> Link: https://lore.kernel.org/r/Y0kuaO9PQkSQja+A@kili Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 65f2030 commit dd4753f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/iio/imu/bno055/bno055.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ static int bno055_set_regmask(struct bno055_priv *priv, int val, int val2,
632632
return -EINVAL;
633633
}
634634
delta = abs(tbl_val - req_val);
635-
if (delta < best_delta || first) {
635+
if (first || delta < best_delta) {
636636
best_delta = delta;
637637
hwval = i;
638638
first = false;

0 commit comments

Comments
 (0)