diff options
author | Marek Vasut <marex@denx.de> | 2024-08-14 21:19:09 +0200 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2024-08-17 16:37:37 +0200 |
commit | 076c4d18de4e93591641d03fb921875c02b30eb3 (patch) | |
tree | 0e092ce152369ac7eec8dc1617871c05d5276e33 /drivers/iio | |
parent | iio: humidity: Add support for ENS210 (diff) | |
download | linux-076c4d18de4e93591641d03fb921875c02b30eb3.tar.xz linux-076c4d18de4e93591641d03fb921875c02b30eb3.zip |
iio: light: noa1305: Fix up integration time look up
The current code is always iterating over two fields in the
noa1305_int_time_available array. Fix iteration limit, which
has to be halved to avoid out of bounds access in case the
value that is being looked up is not in the array.
Fixes: 025f23cfebad ("iio: light: noa1305: Make integration time configurable")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Suggested-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Marek Vasut <marex@denx.de>
Link: https://patch.msgid.link/20240814191946.81386-1-marex@denx.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/light/noa1305.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/iio/light/noa1305.c b/drivers/iio/light/noa1305.c index da83425fd910..25f63da70297 100644 --- a/drivers/iio/light/noa1305.c +++ b/drivers/iio/light/noa1305.c @@ -197,7 +197,7 @@ static int noa1305_write_raw(struct iio_dev *indio_dev, return -EINVAL; /* Look up integration time register settings and write it if found. */ - for (i = 0; i < ARRAY_SIZE(noa1305_int_time_available); i++) + for (i = 0; i < ARRAY_SIZE(noa1305_int_time_available) / 2; i++) if (noa1305_int_time_available[2 * i + 1] == val2) return regmap_write(priv->regmap, NOA1305_REG_INTEGRATION_TIME, i); |