Skip to content

Commit

Permalink
iio: addac: ad74413r: fix off by one in ad74413r_parse_channel_config()
Browse files Browse the repository at this point in the history
The > needs to be >= to prevent accessing one element beyond the end of
the st->channel_configs[] array.

Fixes: fea251b ("iio: addac: add AD74413R driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Cosmin Tanislav <cosmin.tanislav@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
  • Loading branch information
Dan Carpenter authored and Jonathan Cameron committed Dec 16, 2021
1 parent 0a52c3f commit 5d97d9e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/iio/addac/ad74413r.c
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,7 @@ static int ad74413r_parse_channel_config(struct iio_dev *indio_dev,
return ret;
}

if (index > AD74413R_CHANNEL_MAX) {
if (index >= AD74413R_CHANNEL_MAX) {
dev_err(st->dev, "Channel index %u is too large\n", index);
return -EINVAL;
}
Expand Down

0 comments on commit 5d97d9e

Please sign in to comment.