linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 4.4 01/23] tty: serial: fsl_lpuart: fix the potential risk of division or modulo by zero
@ 2021-07-10  2:38 Sasha Levin
  2021-07-10  2:38 ` [PATCH AUTOSEL 4.4 02/23] misc/libmasm/module: Fix two use after free in ibmasm_init_one Sasha Levin
                   ` (21 more replies)
  0 siblings, 22 replies; 23+ messages in thread
From: Sasha Levin @ 2021-07-10  2:38 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Sherry Sun, Greg Kroah-Hartman, Sasha Levin, linux-serial

From: Sherry Sun <sherry.sun@nxp.com>

[ Upstream commit fcb10ee27fb91b25b68d7745db9817ecea9f1038 ]

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 <sherry.sun@nxp.com>
Link: https://lore.kernel.org/r/20210427021226.27468-1-sherry.sun@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/tty/serial/fsl_lpuart.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index 1544a7cc76ff..1319f3dd5b70 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -1681,6 +1681,9 @@ lpuart32_console_get_options(struct lpuart_port *sport, int *baud,
 
 	bd = lpuart32_read(sport->port.membase + UARTBAUD);
 	bd &= UARTBAUD_SBR_MASK;
+	if (!bd)
+		return;
+
 	sbr = bd;
 	uartclk = clk_get_rate(sport->clk);
 	/*
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2021-07-10  2:43 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-10  2:38 [PATCH AUTOSEL 4.4 01/23] tty: serial: fsl_lpuart: fix the potential risk of division or modulo by zero Sasha Levin
2021-07-10  2:38 ` [PATCH AUTOSEL 4.4 02/23] misc/libmasm/module: Fix two use after free in ibmasm_init_one Sasha Levin
2021-07-10  2:38 ` [PATCH AUTOSEL 4.4 03/23] Revert "ALSA: bebob/oxfw: fix Kconfig entry for Mackie d.2 Pro" Sasha Levin
2021-07-10  2:38 ` [PATCH AUTOSEL 4.4 04/23] scsi: lpfc: Fix "Unexpected timeout" error in direct attach topology Sasha Levin
2021-07-10  2:38 ` [PATCH AUTOSEL 4.4 05/23] tty: serial: 8250: serial_cs: Fix a memory leak in error handling path Sasha Levin
2021-07-10  2:38 ` [PATCH AUTOSEL 4.4 06/23] fs/jfs: Fix missing error code in lmLogInit() Sasha Levin
2021-07-10  2:38 ` [PATCH AUTOSEL 4.4 07/23] scsi: iscsi: Add iscsi_cls_conn refcount helpers Sasha Levin
2021-07-10  2:38 ` [PATCH AUTOSEL 4.4 08/23] mfd: da9052/stmpe: Add and modify MODULE_DEVICE_TABLE Sasha Levin
2021-07-10  2:38 ` [PATCH AUTOSEL 4.4 09/23] USB: core: Avoid WARNings for 0-length descriptor requests Sasha Levin
2021-07-10  2:38 ` [PATCH AUTOSEL 4.4 10/23] ALSA: sb: Fix potential double-free of CSP mixer elements Sasha Levin
2021-07-10  2:39 ` [PATCH AUTOSEL 4.4 11/23] powerpc/ps3: Add dma_mask to ps3_dma_region Sasha Levin
2021-07-10  2:39 ` [PATCH AUTOSEL 4.4 12/23] gpio: zynq: Check return value of pm_runtime_get_sync Sasha Levin
2021-07-10  2:39 ` [PATCH AUTOSEL 4.4 13/23] ALSA: ppc: fix error return code in snd_pmac_probe() Sasha Levin
2021-07-10  2:39 ` [PATCH AUTOSEL 4.4 14/23] selftests/powerpc: Fix "no_handler" EBB selftest Sasha Levin
2021-07-10  2:39 ` [PATCH AUTOSEL 4.4 15/23] ASoC: soc-core: Fix the error return code in snd_soc_of_parse_audio_routing() Sasha Levin
2021-07-10  2:39 ` [PATCH AUTOSEL 4.4 16/23] ALSA: bebob: add support for ToneWeal FW66 Sasha Levin
2021-07-10  2:39 ` [PATCH AUTOSEL 4.4 17/23] usb: gadget: f_hid: fix endianness issue with descriptors Sasha Levin
2021-07-10  2:39 ` [PATCH AUTOSEL 4.4 18/23] usb: gadget: hid: fix error return code in hid_bind() Sasha Levin
2021-07-10  2:39 ` [PATCH AUTOSEL 4.4 19/23] powerpc/boot: Fixup device-tree on little endian Sasha Levin
2021-07-10  2:39 ` [PATCH AUTOSEL 4.4 20/23] backlight: lm3630a: Fix return code of .update_status() callback Sasha Levin
2021-07-10  2:39 ` [PATCH AUTOSEL 4.4 21/23] ALSA: hda: Add IRQ check for platform_get_irq() Sasha Levin
2021-07-10  2:39 ` [PATCH AUTOSEL 4.4 22/23] jfs: fix GPF in diFree Sasha Levin
2021-07-10  2:39 ` [PATCH AUTOSEL 4.4 23/23] lib/decompress_unlz4.c: correctly handle zero-padding around initrds Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).