Skip to content

Commit

Permalink
iio:ad5064: Fix off by one in DAC value range check
Browse files Browse the repository at this point in the history
The DAC value range check allows values one larger than the maximum value, which
effectively results in setting the DAC value to 0. This patch fixes the issue.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
  • Loading branch information
Lars-Peter Clausen authored and Jonathan Cameron committed Mar 2, 2013
1 parent a263026 commit c5ef717
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/iio/dac/ad5064.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ static int ad5064_write_raw(struct iio_dev *indio_dev,

switch (mask) {
case IIO_CHAN_INFO_RAW:
if (val > (1 << chan->scan_type.realbits) || val < 0)
if (val >= (1 << chan->scan_type.realbits) || val < 0)
return -EINVAL;

mutex_lock(&indio_dev->mlock);
Expand Down

0 comments on commit c5ef717

Please sign in to comment.