From 8779e4fd20eace694abfdd8f33ce829677ed2667 Mon Sep 17 00:00:00 2001 From: "Yang, Yu-chu" Date: Thu, 14 Jun 2018 18:49:15 -0700 Subject: [PATCH] HV: uart16550: check the denominator before use To prevent the value is devided by zero, checks the denominator before the calculation. Adding the if statement to check before use. If the baud_rate is equal to zero, using default baud_rate. Signed-off-by: Yang, Yu-chu --- hypervisor/debug/uart16550.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hypervisor/debug/uart16550.c b/hypervisor/debug/uart16550.c index 1de846e75..80d5ec354 100644 --- a/hypervisor/debug/uart16550.c +++ b/hypervisor/debug/uart16550.c @@ -89,6 +89,8 @@ static int uart16550_calc_baud_div(__unused struct tgt_uart *tgt_uart, { uint32_t baud_multiplier = baud_rate < BAUD_460800 ? 16 : 13; + if (baud_rate == 0) + baud_rate = BAUD_115200; *baud_div_ptr = ref_freq / (baud_multiplier * baud_rate); return 0;