diff options
author | Hartmut Knaack <knaack.h@gmx.de> | 2015-08-02 23:43:49 +0300 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2015-08-08 19:30:42 +0300 |
commit | 11218226184b6b2be5cde4bf16f647dda225d4f3 (patch) | |
tree | ddef13faec9a0abe126e70aa013327e5f7c85fe4 /drivers/iio | |
parent | b9fddcdb44c2e274193b119dd6c3af3a9324640a (diff) | |
download | linux-11218226184b6b2be5cde4bf16f647dda225d4f3.tar.xz |
iio:accel:mma8452: check values to be written
Check values to be written to the device for valid lower and upper bounds.
Signed-off-by: Hartmut Knaack <knaack.h@gmx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/accel/mma8452.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index 9607f830a13b..42640b1df870 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c @@ -471,15 +471,17 @@ static int mma8452_write_thresh(struct iio_dev *indio_dev, switch (info) { case IIO_EV_INFO_VALUE: - return mma8452_change_config(data, MMA8452_TRANSIENT_THS, - val & MMA8452_TRANSIENT_THS_MASK); + if (val < 0 || val > MMA8452_TRANSIENT_THS_MASK) + return -EINVAL; + + return mma8452_change_config(data, MMA8452_TRANSIENT_THS, val); case IIO_EV_INFO_PERIOD: steps = (val * USEC_PER_SEC + val2) / mma8452_transient_time_step_us[ mma8452_get_odr_index(data)]; - if (steps > 0xff) + if (steps < 0 || steps > 0xff) return -EINVAL; return mma8452_change_config(data, MMA8452_TRANSIENT_COUNT, |