summaryrefslogtreecommitdiff
path: root/drivers/iio
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2020-01-16 13:08:29 +0300
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2020-01-18 13:33:11 +0000
commit98496ccdf0dd88696203e69542e07ef824c56ead (patch)
treef6aa2016245b1dcd64f58ef787f7385e7ea24079 /drivers/iio
parent84961af78c509d500b9b4a45989e449f048c821a (diff)
iio: accel: bma400: prevent setting accel scale too low
This puts an upper bound on "val2" but it also needs to have a lower bound (BMA400_SCALE_MIN). Fixes: 465c811f1f20 ("iio: accel: Add driver for the BMA400") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/accel/bma400_core.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/iio/accel/bma400_core.c b/drivers/iio/accel/bma400_core.c
index ab4a158b35af..cc77f89c048b 100644
--- a/drivers/iio/accel/bma400_core.c
+++ b/drivers/iio/accel/bma400_core.c
@@ -752,7 +752,8 @@ static int bma400_write_raw(struct iio_dev *indio_dev,
mutex_unlock(&data->mutex);
return ret;
case IIO_CHAN_INFO_SCALE:
- if (val != 0 || val2 > BMA400_SCALE_MAX)
+ if (val != 0 ||
+ val2 < BMA400_SCALE_MIN || val2 > BMA400_SCALE_MAX)
return -EINVAL;
mutex_lock(&data->mutex);