]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
iio: invensense: Prevent possible integer overflow while multiplication
authorKaran Sanghavi <karansanghvi98@gmail.com>
Sun, 3 Nov 2024 08:43:14 +0000 (08:43 +0000)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 7 Dec 2024 17:11:01 +0000 (17:11 +0000)
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>
drivers/iio/common/inv_sensors/inv_sensors_timestamp.c

index c081b5caa475f38228b6cec4f759275bd77ca736..97526ba87b934e59a4fc1d090000b6eb7d33202e 100644 (file)
@@ -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;