staging:iio:dac:ad5686: Check for negative values

Currently it is possible to write negative values to the ad5686's raw attribute.
This will cause undefined behaviour, so reject negative values.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Lars-Peter Clausen 2011-10-19 17:51:28 +02:00 committed by Greg Kroah-Hartman
parent 75bb23a215
commit cd8eca6f77
1 changed files with 1 additions and 1 deletions

View File

@ -327,7 +327,7 @@ static int ad5686_write_raw(struct iio_dev *indio_dev,
switch (mask) {
case 0:
if (val > (1 << chan->scan_type.realbits))
if (val > (1 << chan->scan_type.realbits) || val < 0)
return -EINVAL;
mutex_lock(&indio_dev->mlock);