All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH v2 1/6] serial: 8250: drop err label from serial8250_register_8250_port()
Date: Wed, 14 Oct 2026 06:49:20 +0000	[thread overview]
Message-ID: <sashiko-outbox-170892@kernel.org> (raw)
In-Reply-To: <baf799ad88f9ef43093ae96731f48a5e88d726dd.1791873876.git.jirislaby@kernel.org>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] tty: serial: 8250: missing cancel_delayed_work_sync() for overrun_backoff
- [High] tty: serial: 8250: workqueue list corruption via INIT_DELAYED_WORK()
--

commit c4166af59c093eb0e0aed408aac8356ad1cf88f2
Author: Jiri Slaby (SUSE) <jirislaby@kernel.org>

serial: 8250: drop err label from serial8250_register_8250_port()

This commit refactors serial8250_register_8250_port() to eliminate
goto-based error handling while holding a guard() lock. The port
configuration logic is moved into a new helper,
__serial8250_register_8250_port(), which returns an int and uses plain
returns on failures. The caller then handles resetting uart->port.dev in a
single place.

> diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
> index 11424fef7c08b..7ff307ce6aa88 100644
> --- a/drivers/tty/serial/8250/8250_core.c
> +++ b/drivers/tty/serial/8250/8250_core.c
> @@ -743,46 +743,12 @@ static void serial_8250_overrun_backoff_work(struct work_struct *work)
>  	serial_out(up, UART_IER, up->ier);
>  }

[Severity: High]
Can this background work access hardware registers after the port is
unregistered?

When a port is removed (such as during hot-unplug or driver unbind), it
appears there is no matching cancel_delayed_work_sync() for the
overrun_backoff work. 

If the device memory is unmapped and the delayed work executes, will this
serial_out() trigger a synchronous external abort or use-after-free?

[ ... ]

> @@ -927,9 +891,51 @@ int serial8250_register_8250_port(const struct uart_8250_port *up)
>  	}
>  
>  	return ret;
> +}

[Severity: High]
Does this new helper unconditionally re-initialize the delayed work without
checking if it is already pending?

If a device is unbound and then rebound while the overrun_backoff work is
still pending, __serial8250_register_8250_port() is called again. Towards the
end of the helper, the work is initialized:

	if (up->overrun_backoff_time_ms > 0) {
		...
		INIT_DELAYED_WORK(&uart->overrun_backoff,
				serial_8250_overrun_backoff_work);
	}

Re-initializing an active delayed work item with INIT_DELAYED_WORK() calls
INIT_LIST_HEAD() on its list nodes.

Can this corrupt the timer or workqueue linked lists if the work is still
active from a previous registration?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1791873876.git.jirislaby@kernel.org?part=1

  reply	other threads:[~2026-10-14  6:49 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13  6:48 [PATCH v2 0/6] serial: 8250: make port operations work on struct uart_8250_port Jiri Slaby (SUSE)
2026-10-13  6:48 ` [PATCH v2 1/6] serial: 8250: drop err label from serial8250_register_8250_port() Jiri Slaby (SUSE)
2026-10-14  6:49   ` sashiko-bot [this message]
2026-10-13  6:48 ` [PATCH v2 2/6] serial: 8250_exar: remove useless void * casts Jiri Slaby (SUSE)
2026-10-14  6:49   ` sashiko-bot
2026-10-13  6:48 ` [PATCH v2 3/6] serial: 8250_exar: store the GPIO platform device in struct exar8250 Jiri Slaby (SUSE)
2026-10-14  6:49   ` sashiko-bot
2026-10-13  6:48 ` [PATCH v2 4/6] serial: 8250_lpss: do not touch uninitialized line in ehl_serial_exit() Jiri Slaby (SUSE)
2026-10-13 21:13   ` Andy Shevchenko
2026-10-14  6:49   ` sashiko-bot
2026-10-13  6:48 ` [PATCH v2 5/6] serial: 8250_omap: set priv->line before enabling the IRQ Jiri Slaby (SUSE)
2026-10-14  6:49   ` sashiko-bot
2026-10-13  6:48 ` [PATCH v2 6/6] serial: 8250: make port operations work on struct uart_8250_port Jiri Slaby (SUSE)
2026-10-13  7:33   ` Andy Shevchenko
2026-10-13  7:53     ` Jiri Slaby
2026-10-13  9:09       ` Andy Shevchenko
2026-10-13  9:39         ` Jiri Slaby
2026-10-13 10:00           ` Andy Shevchenko
2026-10-13 10:15             ` Jiri Slaby
2026-10-13 10:54               ` Alejandro Colomar
2026-10-13 10:51           ` Alejandro Colomar
2026-10-13 11:06             ` Jiri Slaby
2026-10-13 13:42               ` Andy Shevchenko
2026-10-14  6:49   ` sashiko-bot

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-170892@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=jirislaby@kernel.org \
    --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 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.