Skip to contentSkip to conversation

patch "iio: imu: adis16480: make sure provided frequency is positive" added to staging-linus

PATCH [email protected] 1 participant 1 message Oct 31, 2019

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

iio: imu: adis16480: make sure provided frequency is positive

to my staging git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
in the staging-linus branch.

The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)

The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.

If you have any questions about this process, please let me know.

From 24e1eb5c0d78cfb9750b690bbe997d4d59170258 Mon Sep 17 00:00:00 2001
From: Alexandru Ardelean <[email protected]>
Date: Tue, 8 Oct 2019 17:15:37 +0300
Subject: iio: imu: adis16480: make sure provided frequency is positive

It could happen that either val or val2 [provided from userspace] is negative. In that case the computed frequency could get a weird value.

Fix this by checking that neither of the 2 variables is negative, and check that the computed result is not-zero.

Fixes e4f959390178 ("iio: imu: adis16480 switch sampling frequency attr to core support")
---
 drivers/iio/imu/adis16480.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/iio/imu/adis16480.c +4 -1
index b99d73887c9f..8743b2f376e2 100644
@@ -317,8 +317,11 @@ static int adis16480_set_freq(struct iio_dev *indio_dev, int val, int val2)
 	struct adis16480 *st = iio_priv(indio_dev);
 	unsigned int t, reg;
 
+	if (val < 0 || val2 < 0)
+		return -EINVAL;
+
 	t =  val * 1000 + val2 / 1000;
-	if (t <= 0)
+	if (t == 0)
 		return -EINVAL;
 
 	/*
Signature · 1 line
2.23.0