Skip to content

Commit

Permalink
staging:iio:dac:ad5686: Check for negative values
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Lars-Peter Clausen authored and Greg Kroah-Hartman committed Oct 19, 2011
1 parent 75bb23a commit cd8eca6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/staging/iio/dac/ad5686.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit cd8eca6

Please sign in to comment.