linux/drivers/iio/imu
Alexandru Ardelean 519808425e iio: imu: adis16460: fix variable signedness
Caught via static-analysis checker:
```
drivers/iio/imu/adis16460.c
   152  static int adis16460_set_freq(struct iio_dev *indio_dev, int val, int val2)
   153  {
   154          struct adis16460 *st = iio_priv(indio_dev);
   155          unsigned int t;
                ^^^^^^^^^^^^^^

   156
   157          t =  val * 1000 + val2 / 1000;
   158          if (t <= 0)
                    ^^^^^^
Unsigned is not less than zero.
```

The types of `val` && `val2` are obtained from the IIO `write_raw` hook, so
userspace can provide negative values, which can cause weird behavior after
conversion to unsigned.

This patch changes the sign of variable `t` so that -EINVAL will be
returned for negative values as well.

Fixes: db6ed4d23d ("iio: imu: Add support for the ADIS16460 IMU")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-08-18 18:53:15 +01:00
..
bmi160 treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
inv_mpu6050 First set of new device support, features and cleanups for IIO in the 5.4 cycle 2019-08-12 22:52:44 +02:00
st_lsm6dsx iio: imu: st_lsm6dsx: make IIO_CHAN_INFO_SCALE shared by type 2019-08-05 16:39:23 +01:00
adis.c iio: imu: adis: Add support for SPI transfer cs_change_delay 2019-07-27 22:52:06 +01:00
adis16400.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
adis16460.c iio: imu: adis16460: fix variable signedness 2019-08-18 18:53:15 +01:00
adis16480.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
adis_buffer.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 149 2019-05-30 11:25:18 -07:00
adis_trigger.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 149 2019-05-30 11:25:18 -07:00
Kconfig iio: imu: Add support for the ADIS16460 IMU 2019-07-27 22:52:06 +01:00
kmx61.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 330 2019-06-05 17:37:06 +02:00
Makefile iio: imu: Add support for the ADIS16460 IMU 2019-07-27 22:52:06 +01:00