WSL2-Linux-Kernel/drivers/tty
Christophe Leroy c829d25e26 serial: cpm_uart: Avoid suspicious locking
[ Upstream commit 36ef11d311 ]

  CHECK   drivers/tty/serial/cpm_uart/cpm_uart_core.c
drivers/tty/serial/cpm_uart/cpm_uart_core.c:1271:39: warning: context imbalance in 'cpm_uart_console_write' - unexpected unlock

Allthough 'nolock' is not expected to change, sparse find the following
form suspicious:

	if (unlikely(nolock)) {
		local_irq_save(flags);
	} else {
		spin_lock_irqsave(&pinfo->port.lock, flags);
	}

	cpm_uart_early_write(pinfo, s, count, true);

	if (unlikely(nolock)) {
		local_irq_restore(flags);
	} else {
		spin_unlock_irqrestore(&pinfo->port.lock, flags);
	}

Rewrite it a more obvious form:

	if (unlikely(oops_in_progress)) {
		local_irq_save(flags);
		cpm_uart_early_write(pinfo, s, count, true);
		local_irq_restore(flags);
	} else {
		spin_lock_irqsave(&pinfo->port.lock, flags);
		cpm_uart_early_write(pinfo, s, count, true);
		spin_unlock_irqrestore(&pinfo->port.lock, flags);
	}

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/f7da5cdc9287960185829cfef681a7d8614efa1f.1691068700.git.christophe.leroy@csgroup.eu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-09-23 11:09:59 +02:00
..
hvc hvc/xen: prevent concurrent accesses to the shared ring 2023-03-30 12:47:48 +02:00
ipwireless
serdev
serial serial: cpm_uart: Avoid suspicious locking 2023-09-23 11:09:59 +02:00
vt vc_screen: reload load of struct vc_data pointer in vcs_write() to avoid UAF 2023-05-24 17:36:54 +01:00
Kconfig
Makefile
amiserial.c
ehv_bytechan.c
goldfish.c
mips_ejtag_fdc.c
moxa.c
moxa.h
mxser.c
n_gsm.c tty: n_gsm: fix the UAF caused by race condition in gsm_cleanup_mux 2023-08-26 14:23:31 +02:00
n_hdlc.c
n_null.c
n_tty.c tty: fix hang on tty device with no_room set 2023-08-03 10:22:29 +02:00
nozomi.c
pty.c
synclink_gt.c
sysrq.c workqueue: Introduce show_one_worker_pool and show_one_workqueue. 2023-05-11 23:00:35 +09:00
tty.h tty: Prevent writing chars during tcsetattr TCSADRAIN/FLUSH 2023-05-11 23:00:16 +09:00
tty_audit.c
tty_baudrate.c
tty_buffer.c
tty_io.c tty: Prevent writing chars during tcsetattr TCSADRAIN/FLUSH 2023-05-11 23:00:16 +09:00
tty_ioctl.c tty: Prevent writing chars during tcsetattr TCSADRAIN/FLUSH 2023-05-11 23:00:16 +09:00
tty_jobctrl.c
tty_ldisc.c
tty_ldsem.c
tty_mutex.c
tty_port.c
ttynull.c
vcc.c