Linux Serial subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "YuanZhe Liu" <25031212351@stu.xidian.edu.cn>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH v2] tty: do not drop hangups during reopen
Date: Mon, 30 Nov 2026 16:27:15 +0000	[thread overview]
Message-ID: <sashiko-outbox-241581@kernel.org> (raw)
In-Reply-To: <20261130161204.5003-1-25031212351@stu.xidian.edu.cn>

> TTY_HUPPED is only cleared after ->open() has returned.  A tty that is
> reopened while still being referenced by another process therefore
> remains marked as hung up for the duration of the new open, including
> while a blocking open sleeps in tty_port_block_til_ready().
> 
> __tty_hangup() ignores hangup requests while TTY_HUPPED is set, so a
> hangup (e.g. from USB disconnect) that races with such an open is
> dropped: the line discipline and the new file reference are not hung up,
> and the port remains initialised while the driver tears down its port
> data.  The blocked open then calls into the driver with the port data
> already gone.
> 
> Clear TTY_HUPPED when reopening the tty, while holding the tty lock, so
> that a hangup racing with the open is not ignored and the line
> discipline and file references are hung up in one go.
> 
> This was found while analysing a NULL-pointer dereference in
> pl2303_dtr_rts() on USB disconnect.  Only compile-tested on x86_64.
> 
> Fixes: d4855e1fc03c ("tty: Reset hupped state on open")
> Cc: stable@vger.kernel.org
> Co-developed-by: Bin Yu <byu@xidian.edu.cn>
> Signed-off-by: Bin Yu <byu@xidian.edu.cn>
> Co-developed-by: Cheng Wen <wencheng@xidian.edu.cn>
> Signed-off-by: Cheng Wen <wencheng@xidian.edu.cn>
> Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261130161204.5003-1-25031212351@stu.xidian.edu.cn?part=1

      reply	other threads:[~2026-11-30 16:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 16:12 [PATCH v2] tty: do not drop hangups during reopen YuanZhe Liu
2026-11-30 16:27 ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-241581@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=25031212351@stu.xidian.edu.cn \
    --cc=linux-serial@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox