summaryrefslogtreecommitdiffstats
path: root/drivers/iio/common
diff options
context:
space:
mode:
authorKaran Sanghavi <karansanghvi98@gmail.com>2024-11-03 08:43:14 +0000
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2024-12-07 17:11:01 +0000
commit6dfc256151e842fa894a2b579f9a4551c6961e2c (patch)
tree0b063303c0e4859e7bbc5c6a3cb9ae2b21520111 /drivers/iio/common
parenta79f049b2eec9bac847717b0551469899ac0e715 (diff)
downloadlinux-stable-6dfc256151e842fa894a2b579f9a4551c6961e2c.tar.gz
linux-stable-6dfc256151e842fa894a2b579f9a4551c6961e2c.tar.bz2
linux-stable-6dfc256151e842fa894a2b579f9a4551c6961e2c.zip
iio: invensense: Prevent possible integer overflow while multiplication
Typecast a variable to int64_t for 64-bit arithmetic multiplication. Signed-off-by: Karan Sanghavi <karansanghvi98@gmail.com> Link: https://scan7.scan.coverity.com/#/project-view/51946/11354?selectedIssue=1586045 Link: https://patch.msgid.link/20241103-coverity1586045integeroverflow-v1-1-43ea37a3f3cd@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/common')
-rw-r--r--drivers/iio/common/inv_sensors/inv_sensors_timestamp.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c b/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
index c081b5caa475..97526ba87b93 100644
--- a/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
+++ b/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
@@ -109,8 +109,8 @@ static bool inv_update_chip_period(struct inv_sensors_timestamp *ts,
static void inv_align_timestamp_it(struct inv_sensors_timestamp *ts)
{
- const int64_t period_min = ts->min_period * ts->mult;
- const int64_t period_max = ts->max_period * ts->mult;
+ const int64_t period_min = (int64_t)ts->min_period * ts->mult;
+ const int64_t period_max = (int64_t)ts->max_period * ts->mult;
int64_t add_max, sub_max;
int64_t delta, jitter;
int64_t adjust;