Commit dd4753f8 authored by Dan Carpenter's avatar Dan Carpenter Committed by Jonathan Cameron

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: 4aefe1c2 ("iio: imu: add Bosch Sensortec BNO055 core driver")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Acked-by: default avatarNuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/Y0kuaO9PQkSQja+A@kiliSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 65f20301
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment