Skip to content

Commit fcb10ee

Browse files
SherrySun5gregkh
authored andcommitted
tty: serial: fsl_lpuart: fix the potential risk of division or modulo by zero
We should be very careful about the register values that will be used for division or modulo operations, althrough the possibility that the UARTBAUD register value is zero is very low, but we had better to deal with the "bad data" of hardware in advance to avoid division or modulo by zero leading to undefined kernel behavior. Signed-off-by: Sherry Sun <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 52008eb commit fcb10ee

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/tty/serial/fsl_lpuart.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2414,6 +2414,9 @@ lpuart32_console_get_options(struct lpuart_port *sport, int *baud,
24142414

24152415
bd = lpuart32_read(&sport->port, UARTBAUD);
24162416
bd &= UARTBAUD_SBR_MASK;
2417+
if (!bd)
2418+
return;
2419+
24172420
sbr = bd;
24182421
uartclk = lpuart_get_baud_clk_rate(sport);
24192422
/*

0 commit comments

Comments
 (0)