summaryrefslogtreecommitdiff
path: root/drivers/iio/trigger
diff options
context:
space:
mode:
authorGustavo A. R. Silva <gustavoars@kernel.org>2021-03-29 23:58:17 +0300
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2021-04-07 10:36:39 +0300
commitc10f8109f78b4e3722003c923e6aeebc73a6134a (patch)
tree45e9d4c687d4eda1652189b8448b30ef15140f01 /drivers/iio/trigger
parent4d84487d963164bf661deff86eaca3d6a789e9cf (diff)
downloadlinux-c10f8109f78b4e3722003c923e6aeebc73a6134a.tar.xz
iio: hrtimer-trigger: Fix potential integer overflow in iio_hrtimer_store_sampling_frequency
Add suffix ULL to constant 1000 in order to avoid a potential integer overflow and give the compiler complete information about the proper arithmetic to use. Notice that this constant is being used in a context that expects an expression of type unsigned long long, but it's currently evaluated using 32-bit arithmetic. Addresses-Coverity-ID: 1503062 ("Unintentional integer overflow") Fixes: dafcf4ed8392 ("iio: hrtimer: Allow sub Hz granularity") Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Link: https://lore.kernel.org/r/20210329205817.GA188755@embeddedor Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/trigger')
-rw-r--r--drivers/iio/trigger/iio-trig-hrtimer.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/iio/trigger/iio-trig-hrtimer.c b/drivers/iio/trigger/iio-trig-hrtimer.c
index 51e362f091c2..716c795d08fb 100644
--- a/drivers/iio/trigger/iio-trig-hrtimer.c
+++ b/drivers/iio/trigger/iio-trig-hrtimer.c
@@ -63,7 +63,7 @@ ssize_t iio_hrtimer_store_sampling_frequency(struct device *dev,
if (integer < 0 || fract < 0)
return -ERANGE;
- val = fract + 1000 * integer; /* mHz */
+ val = fract + 1000ULL * integer; /* mHz */
if (!val || val > UINT_MAX)
return -EINVAL;