iio: ad5755: fix off-by-one on devnr limit check
authorColin Ian King <colin.king@canonical.com>
Mon, 25 Jul 2016 22:40:01 +0000 (23:40 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 31 Oct 2016 11:02:10 +0000 (05:02 -0600)
commit4100d32ab5a3df4292db4cda2396b0896bc3facc
treeb0ca68f9cbd92ff2f4b6e7b43aca308caa8edb0d
parentc1d7471d8f35c403e8a077cea1a0b6e050972fab
iio: ad5755: fix off-by-one on devnr limit check

commit 9d47964bfd471f0dd4c89f28556aec68bffa0020 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/dac/ad5755.c