Skip to content

Commit a06b63a

Browse files
Dan Carpenterjic23
authored andcommitted
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: ad2b473 ("iio: sx9310: Support setting proximity thresholds") Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Stephen Boyd <[email protected]> Reviewed-by: Douglas Anderson <[email protected]> Link: https://lore.kernel.org/r/X8XqwK0z//8sSWJR@mwanda Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 7c53f6b commit a06b63a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/iio/proximity/sx9310.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ static int sx9310_read_thresh(struct sx9310_data *data,
601601
return ret;
602602

603603
regval = FIELD_GET(SX9310_REG_PROX_CTRL8_9_PTHRESH_MASK, regval);
604-
if (regval > ARRAY_SIZE(sx9310_pthresh_codes))
604+
if (regval >= ARRAY_SIZE(sx9310_pthresh_codes))
605605
return -EINVAL;
606606

607607
*val = sx9310_pthresh_codes[regval];

0 commit comments

Comments
 (0)