[PATCH] iio: magn: bmc150: add a lower bounds in bmc150_magn_write_raw()

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

 



The "val" variable comes from the user via iio_write_channel_info().
This code puts an upper bound on "val" but it doesn't check for
negatives so Smatch complains.  I don't think either the bounds
checking is really required, but it's just good to be conservative.

Fixes: 5990dc970367 ("iio: magn: bmc150_magn: add oversampling ratio")
Signed-off-by: Dan Carpenter <error27@xxxxxxxxx>
---
 drivers/iio/magnetometer/bmc150_magn.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/magnetometer/bmc150_magn.c b/drivers/iio/magnetometer/bmc150_magn.c
index 06d5a1ef1fbd..c625416b8bcf 100644
--- a/drivers/iio/magnetometer/bmc150_magn.c
+++ b/drivers/iio/magnetometer/bmc150_magn.c
@@ -537,7 +537,7 @@ static int bmc150_magn_write_raw(struct iio_dev *indio_dev,
 
 	switch (mask) {
 	case IIO_CHAN_INFO_SAMP_FREQ:
-		if (val > data->max_odr)
+		if (val < 0 || val > data->max_odr)
 			return -EINVAL;
 		mutex_lock(&data->mutex);
 		ret = bmc150_magn_set_odr(data, val);
-- 
2.39.1




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux