]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging:iio:adxrs450: Reject out of range calibscale values
authorLars-Peter Clausen <lars@metafoo.de>
Thu, 31 Jan 2013 14:27:00 +0000 (14:27 +0000)
committerJonathan Cameron <jic23@kernel.org>
Sat, 2 Feb 2013 09:21:36 +0000 (09:21 +0000)
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>
drivers/staging/iio/gyro/adxrs450_core.c

index 4c462d36dac95d7eb0ce1f00a012211b48a7fc26..96e52844377bacf9572339e8de826e3899861a0c 100644 (file)
@@ -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;