]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
serial: protect uart_port_dtr_rts() in uart_shutdown() too
authorJiri Slaby (SUSE) <jirislaby@kernel.org>
Fri, 25 Oct 2024 11:05:48 +0000 (11:05 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Nov 2024 00:52:38 +0000 (01:52 +0100)
commit399927f0f875b93f3d5a0336d382ba48b8671eb2
tree87c4f5af32cf0dd94cd38a3f2a5f235f9b0fd8b8
parentfcfc61f63fbe9ce5bcc841654bf866f1f5d458e1
serial: protect uart_port_dtr_rts() in uart_shutdown() too

[ Upstream commit 602babaa84d627923713acaf5f7e9a4369e77473 ]

Commit af224ca2df29 (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>
[Adapted over commit 5701cb8bf50e ("tty: Call ->dtr_rts() parameter
active consistently") not in the tree]
Signed-off-by: Tomas Krcka <krckatom@amazon.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/tty/serial/serial_core.c