Re: [PATCH] tty: port: fix hangup of a reopened tty
From: Greg Kroah-Hartman
Date: Mon Nov 30 2026 - 10:37:58 EST
On Mon, Nov 30, 2026 at 10:14:13PM +0800, YuanZhe Liu wrote:
> Drivers rely on tty_port_tty_vhangup() to synchronously hang up their
> port before releasing port resources at deregistration (e.g. on physical
> disconnect).
>
> tty_vhangup() does nothing if the tty has already been hung up. If the
> tty is reopened while still being referenced by another process, the new
> open may reactivate the port, but TTY_HUPPED is only cleared once the
> open has completed. A hangup request during that window is therefore
> dropped and the port remains initialised while the driver tears down its
> port data.
>
> A blocking open then ends up calling into the driver (e.g. dtr_rts() or
> carrier_raised()) with the port data already gone.
>
> Make sure the port is shut down after tty_vhangup() also when the tty has
> already been hung up.
>
> This was found while analysing a NULL-pointer dereference in
> pl2303_dtr_rts() on disconnect.
>
> Fixes: b48820de8c1a ("tty: port: fix tty_port_tty_vhangup() race")
> Cc: stable@xxxxxxxxxxxxxxx
> Co-developed-by: Bin Yu <byu@xxxxxxxxxxxxx>
> Signed-off-by: Bin Yu <byu@xxxxxxxxxxxxx>
> Co-developed-by: Cheng Wen <wencheng@xxxxxxxxxxxxx>
> Signed-off-by: Cheng Wen <wencheng@xxxxxxxxxxxxx>
> Signed-off-by: YuanZhe Liu <25031212351@xxxxxxxxxxxxxxxxx>
> ---
> drivers/tty/tty_port.c | 21 +++++++++++++++++----
> 1 file changed, 17 insertions(+), 4 deletions(-)
How was this found and tested? And are you sure this isn't fixed in
newer kernel releases? Johan did some work on the hangup path here, so
verifying if that fixed this or not would be good.
Also note that the pl2303 driver might have different issues than all
tty drivers due to them being on the usb bus...
thanks,
greg k-h