hw/timer/exynos4210_mct: fix possible int overflow
authorDmitry Frolov <frolov@swemel.ru>
Tue, 19 Nov 2024 13:02:05 +0000 (13:02 +0000)
committerPeter Maydell <peter.maydell@linaro.org>
Tue, 19 Nov 2024 13:02:05 +0000 (13:02 +0000)
The product "icnto * s->tcntb" may overflow uint32_t.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Dmitry Frolov <frolov@swemel.ru>
Message-id: 20241106083801.219578-2-frolov@swemel.ru
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
hw/timer/exynos4210_mct.c

index e807fe2de9005d6dc135e7f47147ae62d672846a..5c6e139b202a87650051c93afcabc539351329df 100644 (file)
@@ -815,7 +815,7 @@ static uint32_t exynos4210_ltick_cnt_get_cnto(struct tick_timer *s)
         /* Both are counting */
         icnto = remain / s->tcntb;
         if (icnto) {
-            tcnto = remain % (icnto * s->tcntb);
+            tcnto = remain % ((uint64_t)icnto * s->tcntb);
         } else {
             tcnto = remain % s->tcntb;
         }