diff options
author | Colin Ian King <colin.king@canonical.com> | 2016-07-26 00:40:01 +0200 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2016-08-29 17:15:24 +0200 |
commit | 9d47964bfd471f0dd4c89f28556aec68bffa0020 (patch) | |
tree | 2d8019f310f52bc66da8d8ae9ba3540050d10a3f /drivers/iio | |
parent | Merge tag 'iio-for-4.9a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic... (diff) | |
download | linux-9d47964bfd471f0dd4c89f28556aec68bffa0020.tar.xz linux-9d47964bfd471f0dd4c89f28556aec68bffa0020.zip |
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: Colin Ian King <colin.king@canonical.com>
Fixes: c947459979c6 ("iio: ad5755: add support for dt bindings")
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/dac/ad5755.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/iio/dac/ad5755.c b/drivers/iio/dac/ad5755.c index 0fde593ec0d9..5f7968232564 100644 --- a/drivers/iio/dac/ad5755.c +++ b/drivers/iio/dac/ad5755.c @@ -655,7 +655,7 @@ static struct ad5755_platform_data *ad5755_parse_dt(struct device *dev) devnr = 0; for_each_child_of_node(np, pp) { - if (devnr > AD5755_NUM_CHANNELS) { + if (devnr >= AD5755_NUM_CHANNELS) { dev_err(dev, "There is to many channels defined in DT\n"); goto error_out; |