All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Johan Hovold" <johan@kernel.org>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH 05/11] USB: serial: io_edgeport: serialise MCR accesses
Date: Wed, 21 Oct 2026 14:26:55 +0000	[thread overview]
Message-ID: <sashiko-outbox-180370@kernel.org> (raw)
In-Reply-To: <20261021141154.2324793-6-johan@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] usb: serial: io_edgeport: change_port_settings() locks mutex in atomic context
--

commit 12f657a4474c4b2a9d60008b5bffca174179c50e
Author: Johan Hovold <johan@kernel.org>

USB: serial: io_edgeport: serialise MCR accesses

This commit adds a mutex to struct edgeport_port to serialise updates and
reads of shadowMCR across port operations.

> diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
> index 38f58ca115ebd..0b50c6b99b0a8 100644
> --- a/drivers/usb/serial/io_edgeport.c
> +++ b/drivers/usb/serial/io_edgeport.c
[ ... ]
> @@ -2477,12 +2489,14 @@ static void change_port_settings(struct tty_struct *tty,
>  		return;
>  
>  	/* set up the MCR register and send it to the EdgePort */
> +	mutex_lock(&edge_port->mutex);
>  	edge_port->shadowMCR = MCR_MASTER_IE;
>  	if (cflag & CBAUD)
>  		edge_port->shadowMCR |= (MCR_DTR | MCR_RTS);
>  
>  	status = send_cmd_write_uart_register(edge_port, MCR,
>  						edge_port->shadowMCR);
> +	mutex_unlock(&edge_port->mutex);

[Severity: High]
Can this sleep in atomic context when a port is opened?

When edge_open() sends an open command to the device and waits on
edge_port->wait_open, the open response is handled in the bulk-in urb
completion callback while holding edge_serial->es_lock with interrupts
disabled:

drivers/usb/serial/io_edgeport.c:
edge_bulk_in_callback()
    spin_lock_irqsave(&edge_serial->es_lock, flags);
    ...
    process_rcvd_data(edge_serial, data, urb->actual_length);
        -> process_rcvd_status()
            if (code == IOSP_STATUS_OPEN_RSP) {
                ...
                tty = tty_port_tty_get(&edge_port->port->port);
                if (tty) {
                    change_port_settings(tty,
                        edge_port, &tty->termios);
                    tty_kref_put(tty);
                }

Calling mutex_lock(&edge_port->mutex) inside change_port_settings() acquires
a sleepable mutex under spin_lock_irqsave() in hardirq or softirq context.

A subsequent commit in this series moves the initial termios update from
process_rcvd_status() to edge_open(), but having this patch ordered before
that change leaves an intermediate bisection window where opening a port
triggers a sleeping-in-atomic bug, and could also cause a regression when
this commit is backported to stable trees without the follow-up refactoring.

Should the change moving the initial termios update into edge_open() come
before this patch and be included as a prerequisite for stable?

>  	if (status != 0)
>  		return;
>  
[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261021141154.2324793-1-johan@kernel.org?part=5

  reply	other threads:[~2026-10-21 14:26 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-21 14:11 [PATCH 00/11] USB: serial: io_edgeport: fixes and sync commands Johan Hovold
2026-10-21 14:11 ` [PATCH 01/11] USB: serial: io_edgeport: fix NULL-deref on early status Johan Hovold
2026-10-21 14:20   ` sashiko-bot
2026-10-21 14:11 ` [PATCH 02/11] USB: serial: io_edgeport: fix potential fifo corruption Johan Hovold
2026-10-21 14:31   ` sashiko-bot
2026-10-21 14:11 ` [PATCH 03/11] USB: serial: io_edgeport: fix potential close() use-after-free Johan Hovold
2026-10-21 14:37   ` sashiko-bot
2026-10-21 14:11 ` [PATCH 04/11] USB: serial: io_edgeport: fix potential NULL-deref at open Johan Hovold
2026-10-21 14:28   ` sashiko-bot
2026-10-21 14:11 ` [PATCH 05/11] USB: serial: io_edgeport: serialise MCR accesses Johan Hovold
2026-10-21 14:26   ` sashiko-bot [this message]
2026-10-21 15:27     ` Johan Hovold
2026-10-21 14:11 ` [PATCH 06/11] USB: serial: io_edgeport: drop redundant sanity checks Johan Hovold
2026-10-21 14:24   ` sashiko-bot
2026-10-21 14:11 ` [PATCH 07/11] USB: serial: io_edgeport: drop redundant open " Johan Hovold
2026-10-21 14:42   ` sashiko-bot
2026-10-21 14:11 ` [PATCH 08/11] USB: serial: io_edgeport: move initial termios update to open() Johan Hovold
2026-10-21 14:25   ` sashiko-bot
2026-10-21 14:11 ` [PATCH 09/11] USB: serial: io_edgeport: deassert DTR/RTS on close() and B0 Johan Hovold
2026-10-21 14:22   ` sashiko-bot
2026-10-21 14:11 ` [PATCH 10/11] USB: serial: io_edgeport: replace atomic command allocations Johan Hovold
2026-10-21 14:19   ` sashiko-bot
2026-10-21 14:11 ` [PATCH 11/11] USB: serial: io_edgeport: switch to synchronous commands Johan Hovold
2026-10-21 14:23   ` sashiko-bot
2026-10-21 15:43     ` Johan Hovold

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-180370@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=johan@kernel.org \
    --cc=linux-usb@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 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.