From: Karan Sanghavi Date: Sun, 3 Nov 2024 08:43:14 +0000 (+0000) Subject: iio: invensense: Prevent possible integer overflow while multiplication X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=6dfc256151e842fa894a2b579f9a4551c6961e2c;p=users%2Fjedix%2Flinux-maple.git iio: invensense: Prevent possible integer overflow while multiplication Typecast a variable to int64_t for 64-bit arithmetic multiplication. Signed-off-by: Karan Sanghavi 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 --- 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;