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

iio: light: apds9306: Fix off by one in apds9306_sampling_freq_get()

The > comparison needs to be >= to prevent an out of bounds access.

Fixes: 620d1e6c ("iio: light: Add support for APDS9306 Light Sensor")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: default avatarSubhajit Ghosh <subhajit.ghosh@tweaklogic.com>
Link: https://lore.kernel.org/r/69c5cb83-0209-40ff-a276-a0ae5e81c528@moroto.mountainSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 2f896dd9
......@@ -635,7 +635,7 @@ static int apds9306_sampling_freq_get(struct apds9306_data *data, int *val,
if (ret)
return ret;
if (repeat_rate_idx > ARRAY_SIZE(apds9306_repeat_rate_freq))
if (repeat_rate_idx >= ARRAY_SIZE(apds9306_repeat_rate_freq))
return -EINVAL;
*val = apds9306_repeat_rate_freq[repeat_rate_idx][0];
......
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