mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-06 17:35:20 +02:00
serial: protect uart_port_dtr_rts() in uart_shutdown() too
[ Upstream commit602babaa84
] Commitaf224ca2df
(serial: core: Prevent unsafe uart port access, part 3) added few uport == NULL checks. It added one to uart_shutdown(), so the commit assumes, uport can be NULL in there. But right after that protection, there is an unprotected "uart_port_dtr_rts(uport, false);" call. That is invoked only if HUPCL is set, so I assume that is the reason why we do not see lots of these reports. Or it cannot be NULL at this point at all for some reason :P. Until the above is investigated, stay on the safe side and move this dereference to the if too. I got this inconsistency from Coverity under CID 1585130. Thanks. Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org> Cc: Peter Hurley <peter@hurleysoftware.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Link: https://lore.kernel.org/r/20240805102046.307511-3-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
339273a9dd
commit
e418d91195
|
@ -374,14 +374,16 @@ static void uart_shutdown(struct tty_struct *tty, struct uart_state *state)
|
||||||
/*
|
/*
|
||||||
* Turn off DTR and RTS early.
|
* Turn off DTR and RTS early.
|
||||||
*/
|
*/
|
||||||
if (uport && uart_console(uport) && tty) {
|
if (uport) {
|
||||||
uport->cons->cflag = tty->termios.c_cflag;
|
if (uart_console(uport) && tty) {
|
||||||
uport->cons->ispeed = tty->termios.c_ispeed;
|
uport->cons->cflag = tty->termios.c_cflag;
|
||||||
uport->cons->ospeed = tty->termios.c_ospeed;
|
uport->cons->ispeed = tty->termios.c_ispeed;
|
||||||
}
|
uport->cons->ospeed = tty->termios.c_ospeed;
|
||||||
|
}
|
||||||
|
|
||||||
if (!tty || C_HUPCL(tty))
|
if (!tty || C_HUPCL(tty))
|
||||||
uart_port_dtr_rts(uport, false);
|
uart_port_dtr_rts(uport, false);
|
||||||
|
}
|
||||||
|
|
||||||
uart_port_shutdown(port);
|
uart_port_shutdown(port);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user