Re: [PATCH v2] iio: accel: bma400: prevent setting accel scale too low

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 16 Jan 2020 13:08:29 +0300
Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote:

> 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@xxxxxxxxxx>

Applied to the togreg branch of iio.git and pushed out as testing.
Hopefully I'll sneak in a pull request to get this lined up for
the merge window.

Thanks,

Jonathan

> ---
> v2: the first version just capped it at zero but it should be
>     BMA400_SCALE_MIN (38357).
> 
>  drivers/iio/accel/bma400_core.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> 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);




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux