iio:gyro: adis16136: divide by zero in write_frequency()
Subsystems (3)
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
@@ -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 6 lines · Dan Carpenter
It's slightly cleaner to use
kstrtouint()because we pass unsigned ints toadis16136_set_freq(). On 64 bit systems, if the user passedLONG_MINthen it we would get past the test against zero but crash inadis16136_set_freq()because we truncate the high bits away.
Thanks,
Quoted 22 lines
drivers/iio/gyro/adis16136.c +2
-3@@ -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
Jonathan Cameron
maintainerQuoted 8 lines · Lars-Peter Clausen
Quoted 6 lines · Dan Carpenter
It's slightly cleaner to use
kstrtouint()because we pass unsigned ints toadis16136_set_freq(). On 64 bit systems, if the user passedLONG_MINthen it we would get past the test against zero but crash inadis16136_set_freq()because we truncate the high bits away.
Quoted 5 lines
Thanks,
Signed-off-by Dan Carpenter <[email protected]>
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@@ -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