summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2011-10-19 15:51:28 (GMT)
committerGreg Kroah-Hartman <gregkh@suse.de>2011-10-19 20:57:05 (GMT)
commitcd8eca6f77108617a8c47a800533f1b78a357a79 (patch)
treea75244bd5b24513bdbb04a8c5c7d2cd79aac8771
parent75bb23a2150e385230d1db52065641ca7cef63d3 (diff)
downloadlinux-fsl-qoriq-cd8eca6f77108617a8c47a800533f1b78a357a79.tar.xz
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>
-rw-r--r--drivers/staging/iio/dac/ad5686.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/staging/iio/dac/ad5686.c b/drivers/staging/iio/dac/ad5686.c
index 1d50dd1..48389e1 100644
--- a/drivers/staging/iio/dac/ad5686.c
+++ b/drivers/staging/iio/dac/ad5686.c
@@ -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);