linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: accel: bma400: integer underflow setting accel scale
@ 2020-01-15 17:45 Dan Carpenter
  2020-01-15 17:43 ` Dan Robertson
  2020-01-15 18:17 ` Dan Robertson
  0 siblings, 2 replies; 8+ messages in thread
From: Dan Carpenter @ 2020-01-15 17:45 UTC (permalink / raw)
  To: Dan Robertson
  Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Linus Walleij, Andy Shevchenko,
	linux-iio, kernel-janitors

We put an upper bound on "val2" but we also need to prevent negative
values.

Fixes: 465c811f1f20 ("iio: accel: Add driver for the BMA400")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/iio/accel/bma400_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/accel/bma400_core.c b/drivers/iio/accel/bma400_core.c
index ab4a158b35af..ffc7b146bbfc 100644
--- a/drivers/iio/accel/bma400_core.c
+++ b/drivers/iio/accel/bma400_core.c
@@ -752,7 +752,7 @@ 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 < 0 || val2 > BMA400_SCALE_MAX)
 			return -EINVAL;
 
 		mutex_lock(&data->mutex);
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-01-18 13:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-15 17:45 [PATCH] iio: accel: bma400: integer underflow setting accel scale Dan Carpenter
2020-01-15 17:43 ` Dan Robertson
2020-01-15 18:09   ` Dan Carpenter
2020-01-15 17:58     ` Dan Robertson
2020-01-15 18:17 ` Dan Robertson
2020-01-16  6:24   ` Dan Carpenter
2020-01-16 10:08   ` [PATCH v2] iio: accel: bma400: prevent setting accel scale too low Dan Carpenter
2020-01-18 13:34     ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).