summaryrefslogtreecommitdiff
path: root/hw/timer/exynos4210_mct.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2014-05-13 16:09:39 +0100
committerPeter Maydell <peter.maydell@linaro.org>2014-05-13 16:09:39 +0100
commitc3a699be3c63f75b6ea5877080ea9b96b37524c4 (patch)
tree87ec036eaca6e0a25e0c50b568b4849a25a144e7 /hw/timer/exynos4210_mct.c
parent2a41c92854385eb1ae677e79257e136886200ace (diff)
downloadqemu-c3a699be3c63f75b6ea5877080ea9b96b37524c4.tar.gz
hw/timer/exynos4210_mct: Avoid overflow in exynos4210_ltick_recalc_count
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>
Diffstat (limited to 'hw/timer/exynos4210_mct.c')
-rw-r--r--hw/timer/exynos4210_mct.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c
index 01e750e131..015bbaf1bd 100644
--- a/hw/timer/exynos4210_mct.c
+++ b/hw/timer/exynos4210_mct.c
@@ -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;
}