summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2013-01-31 14:27:00 +0000
committerJonathan Cameron <jic23@kernel.org>2013-02-02 09:21:36 +0000
commit9a26578c811e6f4de24d81ef734b17c401e5080f (patch)
treec92986a19761828bf2a2c97dc67deb8ab95f95f7
parentc62b89c713ebd5e4a67c9b9229591adab8953a3c (diff)
downloadop-kernel-dev-9a26578c811e6f4de24d81ef734b17c401e5080f.zip
op-kernel-dev-9a26578c811e6f4de24d81ef734b17c401e5080f.tar.gz
staging:iio:adxrs450: Reject out of range calibscale values
Instead of silently discarding the upper bits reject out of range values for the calibscale property. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r--drivers/staging/iio/gyro/adxrs450_core.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/staging/iio/gyro/adxrs450_core.c b/drivers/staging/iio/gyro/adxrs450_core.c
index 4c462d3..96e5284 100644
--- a/drivers/staging/iio/gyro/adxrs450_core.c
+++ b/drivers/staging/iio/gyro/adxrs450_core.c
@@ -258,9 +258,10 @@ static int adxrs450_write_raw(struct iio_dev *indio_dev,
int ret;
switch (mask) {
case IIO_CHAN_INFO_CALIBBIAS:
+ if (val < -0x400 || val >= 0x400)
+ return -EINVAL;
ret = adxrs450_spi_write_reg_16(indio_dev,
- ADXRS450_DNC1,
- val & 0x3FF);
+ ADXRS450_DNC1, val);
break;
default:
ret = -EINVAL;
OpenPOWER on IntegriCloud