Skip to contentSkip to conversation

iio:gyro: adis16136: divide by zero in write_frequency()

PATCH In review Dan Carpenter 3 participants 3 messages Nov 27, 2012 – Nov 30, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio:gyro: adis16136: divide by zero in write_frequency()

It's slightly cleaner to use kstrtouint() because we pass unsigned ints to adis16136_set_freq(). On 64 bit systems, if the user passed LONG_MIN then it we would get past the test against zero but crash in adis16136_set_freq() because we truncate the high bits away.

drivers/iio/gyro/adis16136.c +2 -2
index 05486df..b4ee339 100644
@@ -203,10 +203,10 @@ static ssize_t adis16136_write_frequency(struct device *dev,
 {
 	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
 	struct adis16136 *adis16136 = iio_priv(indio_dev);
-	long val;
+	unsigned int val;
 	int ret;
 
-	ret = kstrtol(buf, 10, &val);
+	ret = kstrtouint(buf, 10, &val);
 	if (ret)
 		return ret;
 
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Dan Carpenter

It's slightly cleaner to use kstrtouint() because we pass unsigned ints to adis16136_set_freq(). On 64 bit systems, if the user passed LONG_MIN then it we would get past the test against zero but crash in adis16136_set_freq() because we truncate the high bits away.

Thanks,

Quoted 22 lines
drivers/iio/gyro/adis16136.c +2 -3
index 05486df..b4ee339 100644
@@ -203,10 +203,10 @@ static ssize_t adis16136_write_frequency(struct device *dev,
 {
 	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
 	struct adis16136 *adis16136 = iio_priv(indio_dev);
-	long val;
+	unsigned int val;
 	int ret;
 
-	ret = kstrtol(buf, 10, &val);
+	ret = kstrtouint(buf, 10, &val);
 	if (ret)
 		return ret;
 
--

To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#2 lore raw
Quoted 8 lines · Lars-Peter Clausen
Quoted 6 lines · Dan Carpenter

It's slightly cleaner to use kstrtouint() because we pass unsigned ints to adis16136_set_freq(). On 64 bit systems, if the user passed LONG_MIN then it we would get past the test against zero but crash in adis16136_set_freq() because we truncate the high bits away.

Quoted 5 lines

Thanks,

Added to togreg branch of

git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git

Quoted 28 lines
Quoted 19 lines
drivers/iio/gyro/adis16136.c +2 -3
index 05486df..b4ee339 100644
@@ -203,10 +203,10 @@ static ssize_t adis16136_write_frequency(struct device *dev,
 {
 	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
 	struct adis16136 *adis16136 = iio_priv(indio_dev);
-	long val;
+	unsigned int val;
 	int ret;
 
-	ret = kstrtol(buf, 10, &val);
+	ret = kstrtouint(buf, 10, &val);
 	if (ret)
 		return ret;
 
--
Quoted 3 lines

To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html