Received: from eggs.gnu.org ([2001:4830:134:3::10]:35272) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byj0K-0006Sj-LJ for qemu-devel@nongnu.org; Mon, 24 Oct 2016 13:25:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1byj0I-0007So-Ct for qemu-devel@nongnu.org; Mon, 24 Oct 2016 13:25:44 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:47422) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1byj0I-0007QU-1j for qemu-devel@nongnu.org; Mon, 24 Oct 2016 13:25:42 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1byj0H-0002Ql-6L for qemu-devel@nongnu.org; Mon, 24 Oct 2016 18:25:41 +0100 From: Peter Maydell Date: Mon, 24 Oct 2016 18:25:22 +0100 Message-Id: <1477329928-26414-27-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1477329928-26414-1-git-send-email-peter.maydell@linaro.org> References: <1477329928-26414-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PULL 26/32] timer: stm32f2xx_timer: add check for prescaler value List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org From: Prasad J Pandit The STM32F2XX Timer emulator uses a 16 bit prescaler value to limit the timer clock rate. It does that by dividing the timer frequency. If the prescaler 's->tim_psc' was set to be UINT_MAX, it'd lead to divide by zero error. Limit prescaler value to 16 bits to avoid it. Reported-by: Huawei PSIRT Signed-off-by: Prasad J Pandit Message-id: 1476800269-31902-1-git-send-email-ppandit@redhat.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/timer/stm32f2xx_timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/timer/stm32f2xx_timer.c b/hw/timer/stm32f2xx_timer.c index 8c4c1f9..e5f5e14 100644 --- a/hw/timer/stm32f2xx_timer.c +++ b/hw/timer/stm32f2xx_timer.c @@ -217,7 +217,7 @@ static void stm32f2xx_timer_write(void *opaque, hwaddr offset, return; case TIM_PSC: timer_val = stm32f2xx_ns_to_ticks(s, now) - s->tick_offset; - s->tim_psc = value; + s->tim_psc = value & 0xFFFF; value = timer_val; break; case TIM_CNT: -- 2.7.4