Linux IIO development
 help / color / mirror / Atom feed
* [PATCH] iio: invensense: fix integer overflow while multiplication
@ 2024-11-03  8:43 Karan Sanghavi
  2024-11-03 11:18 ` Jonathan Cameron
  0 siblings, 1 reply; 5+ messages in thread
From: Karan Sanghavi @ 2024-11-03  8:43 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen
  Cc: linux-iio, linux-kernel, Shuah Khan, Anup, Karan Sanghavi

Typecast a variable to int64_t for 64-bit arithmetic multiplication

Signed-off-by: Karan Sanghavi <karansanghvi98@gmail.com>
---
 drivers/iio/common/inv_sensors/inv_sensors_timestamp.c | 4 ++--
 1 file 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 f44458c380d9..d1d11d0b2458 100644
--- a/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
+++ b/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
@@ -105,8 +105,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;

---
base-commit: 81983758430957d9a5cb3333fe324fd70cf63e7e
change-id: 20241102-coverity1586045integeroverflow-cbbf357475d9

Best regards,
-- 
Karan Sanghavi <karansanghvi98@gmail.com>


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-11-09 15:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-03  8:43 [PATCH] iio: invensense: fix integer overflow while multiplication Karan Sanghavi
2024-11-03 11:18 ` Jonathan Cameron
2024-11-04 16:26   ` Karan Sanghavi
2024-11-09 15:28     ` Jonathan Cameron
2024-11-05 17:39   ` Karan Sanghavi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox