From: sashiko-bot@kernel.org
To: "Tapio Reijonen" <tapio.reijonen@vaisala.com>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH 3/3] serial: max310x: hold the port lock around the CTS change
Date: Fri, 20 Nov 2026 07:41:40 +0000 [thread overview]
Message-ID: <sashiko-outbox-224646@kernel.org> (raw)
In-Reply-To: <20261120-max310x-teardown-fixes-v1-3-eb52c8b612df@vaisala.com>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] serial: max310x: lockless access to xmit_fifo in
max310x_handle_tx() [1]
--
commit b6f9f6d1c6352edbe4d9493e77cb10be6d1f66a0
Author: Tapio Reijonen <tapio.reijonen@vaisala.com>
serial: max310x: hold the port lock around the CTS change
This commit acquires the UART port lock around uart_handle_cts_change() in
max310x_port_irq().
> diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
> index 179f5f4cc7b2f..b2d887316957c 100644
> --- a/drivers/tty/serial/max310x.c
> +++ b/drivers/tty/serial/max310x.c
> @@ -1043,7 +1043,8 @@ static irqreturn_t max310x_port_irq(struct max310x_port *s, int portno)
>
> if (ists & MAX310X_IRQ_CTS_BIT) {
> lsr = max310x_port_read(port, MAX310X_LSR_IRQSTS_REG);
> - uart_handle_cts_change(port, lsr & MAX310X_LSR_CTS_BIT);
> + scoped_guard(uart_port_lock_irqsave, port)
> + uart_handle_cts_change(port, lsr & MAX310X_LSR_CTS_BIT);
> }
> if (rxlen)
> max310x_handle_rx(port, rxlen);
[Severity: High]
This problem wasn't introduced by this patch, but does max310x_handle_tx()
also race on tport->xmit_fifo and port->icount.tx without holding port->lock
[1]?
drivers/tty/serial/max310x.c:max310x_handle_tx() {
...
while (!kfifo_is_empty(&tport->xmit_fifo)) {
...
to_send = kfifo_out_linear_ptr(&tport->xmit_fifo, &tail, txlen);
max310x_batch_write(port, tail, to_send);
uart_xmit_advance(port, to_send);
}
if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
uart_write_wakeup(port);
}
Callers such as uart_write() modify tport->xmit_fifo under port->lock, while
the tx_work worker drains it and calls uart_xmit_advance() and
uart_write_wakeup() locklessly, which can corrupt the transmit FIFO state
and send garbage or drop characters.
[1] https://sashiko.dev/#/bug/linux-10a0ea86-42c1-439b-aa6f-385dd9c88f23
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120-max310x-teardown-fixes-v1-0-eb52c8b612df@vaisala.com?part=3
prev parent reply other threads:[~2026-11-20 7:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 7:33 [PATCH 0/3] serial: max310x: teardown ordering and CTS locking fixes Tapio Reijonen
2026-11-20 7:33 ` [PATCH 1/3] serial: max310x: fix use-after-free on remove Tapio Reijonen
2026-11-20 7:45 ` sashiko-bot
2026-11-20 7:33 ` [PATCH 2/3] serial: max310x: unwind only the registered ports when probe fails Tapio Reijonen
2026-11-20 7:39 ` sashiko-bot
2026-11-20 7:33 ` [PATCH 3/3] serial: max310x: hold the port lock around the CTS change Tapio Reijonen
2026-11-20 7:41 ` 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-224646@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tapio.reijonen@vaisala.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.