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

iio: sx9310: Off by one in sx9310_read_thresh()

This > should be >= to prevent reading one element beyond the end of
the sx9310_pthresh_codes[] array.

Fixes: ad2b473e ("iio: sx9310: Support setting proximity thresholds")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: default avatarStephen Boyd <swboyd@chromium.org>
Reviewed-by: default avatarDouglas Anderson <dianders@chromium.org>
Link: https://lore.kernel.org/r/X8XqwK0z//8sSWJR@mwandaSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 7c53f6b6
...@@ -601,7 +601,7 @@ static int sx9310_read_thresh(struct sx9310_data *data, ...@@ -601,7 +601,7 @@ static int sx9310_read_thresh(struct sx9310_data *data,
return ret; return ret;
regval = FIELD_GET(SX9310_REG_PROX_CTRL8_9_PTHRESH_MASK, regval); regval = FIELD_GET(SX9310_REG_PROX_CTRL8_9_PTHRESH_MASK, regval);
if (regval > ARRAY_SIZE(sx9310_pthresh_codes)) if (regval >= ARRAY_SIZE(sx9310_pthresh_codes))
return -EINVAL; return -EINVAL;
*val = sx9310_pthresh_codes[regval]; *val = sx9310_pthresh_codes[regval];
......
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