Commit 98496ccd authored by Dan Carpenter's avatar Dan Carpenter Committed by Jonathan Cameron

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: 465c811f ("iio: accel: Add driver for the BMA400")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 84961af7
...@@ -752,7 +752,8 @@ static int bma400_write_raw(struct iio_dev *indio_dev, ...@@ -752,7 +752,8 @@ static int bma400_write_raw(struct iio_dev *indio_dev,
mutex_unlock(&data->mutex); mutex_unlock(&data->mutex);
return ret; return ret;
case IIO_CHAN_INFO_SCALE: 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; return -EINVAL;
mutex_lock(&data->mutex); mutex_lock(&data->mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment