Commit 9d47964b authored by Colin Ian King's avatar Colin Ian King Committed by Jonathan Cameron

iio: ad5755: fix off-by-one on devnr limit check

The comparison for devnr limits is off-by-one, the current check
allows 0 to AD5755_NUM_CHANNELS and the limit should be in fact
0 to AD5755_NUM_CHANNELS - 1.  This can lead to an out of bounds
write to pdata->dac[devnr]. Fix this by replacing > with >= on the
comparison.
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Fixes: c9474599 ("iio: ad5755: add support for dt bindings")
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent d5bd1eba
...@@ -655,7 +655,7 @@ static struct ad5755_platform_data *ad5755_parse_dt(struct device *dev) ...@@ -655,7 +655,7 @@ static struct ad5755_platform_data *ad5755_parse_dt(struct device *dev)
devnr = 0; devnr = 0;
for_each_child_of_node(np, pp) { for_each_child_of_node(np, pp) {
if (devnr > AD5755_NUM_CHANNELS) { if (devnr >= AD5755_NUM_CHANNELS) {
dev_err(dev, dev_err(dev,
"There is to many channels defined in DT\n"); "There is to many channels defined in DT\n");
goto error_out; goto error_out;
......
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