Skip to content

Commit 8779e4f

Browse files
yuchuyanglijinxia
authored andcommitted
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 <yu-chu.yang@intel.com>
1 parent b5b83ca commit 8779e4f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

hypervisor/debug/uart16550.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ static int uart16550_calc_baud_div(__unused struct tgt_uart *tgt_uart,
8989
{
9090
uint32_t baud_multiplier = baud_rate < BAUD_460800 ? 16 : 13;
9191

92+
if (baud_rate == 0)
93+
baud_rate = BAUD_115200;
9294
*baud_div_ptr = ref_freq / (baud_multiplier * baud_rate);
9395

9496
return 0;

0 commit comments

Comments
 (0)