]> xenbits.xensource.com Git - qemu-upstream-4.6-testing.git/commitdiff
hw/timer/exynos4210_mct: Avoid overflow in exynos4210_ltick_recalc_count
authorPeter Maydell <peter.maydell@linaro.org>
Tue, 13 May 2014 15:09:39 +0000 (16:09 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Tue, 13 May 2014 15:09:39 +0000 (16:09 +0100)
Add casts to avoid potentially overflowing the multiplications
of 32 bit quantities in exynos4210_ltick_recalc_count().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
hw/timer/exynos4210_mct.c

index 01e750e131711da8c449f17295e7527073cb3f9b..015bbaf1bd1febb864749a92e836af22d607e295 100644 (file)
@@ -818,14 +818,14 @@ static void exynos4210_ltick_recalc_count(struct tick_timer *s)
          */
 
         if (s->last_tcnto) {
-            to_count = s->last_tcnto * s->last_icnto;
+            to_count = (uint64_t)s->last_tcnto * s->last_icnto;
         } else {
             to_count = s->last_icnto;
         }
     } else {
         /* distance is passed, recalculate with tcnto * icnto */
         if (s->icntb) {
-            s->distance = s->tcntb * s->icntb;
+            s->distance = (uint64_t)s->tcntb * s->icntb;
         } else {
             s->distance = s->tcntb;
         }