Linux Serial subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Linmao Li" <lilinmao@kylinos.cn>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH v2 2/3] serial: 8250_mxpcie: only unregister the ports that were registered
Date: Tue, 01 Sep 2026 04:27:49 +0000	[thread overview]
Message-ID: <20260901042749.AF29A1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260901041519.114737-3-lilinmao@kylinos.cn>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The driver fails to initialize `up.port.port_id` for individual serial ports during probe, causing all successfully registered ports to incorrectly share `port_id = 0`. This leads to configuration meant for other ports silently overwriting port 0's hardware registers and software state.
--

commit 73e9e979a09f1fbc7bf6f2134b67c8afbd507c55
Author: Linmao Li <lilinmao@kylinos.cn>

    serial: 8250_mxpcie: only unregister the ports that were registered
    
    When serial8250_register_8250_port() fails the loop stops and the probe
    keeps the ports registered so far, like pciserial_init_ports() in
    8250_pci.c this driver was split from.  What the split lost is that
    function's priv->nr: mxpcie8250_remove() walks all num_ports entries,
    but the ones the loop never reached keep the zero devm_kzalloc() left
    there, and the one that failed keeps a negative error code.

> diff --git a/drivers/tty/serial/8250/8250_mxpcie.c b/drivers/tty/serial/8250/8250_mxpcie.c
> index c0e3517d4e4ec..ef2516ec16da0 100644
> --- a/drivers/tty/serial/8250/8250_mxpcie.c
> +++ b/drivers/tty/serial/8250/8250_mxpcie.c
[ ... ]
> @@ -564,7 +566,7 @@ static int mxpcie8250_probe(struct pci_dev *pdev, const struct pci_device_id *id
>  	up.port.handle_irq = mxpcie8250_handle_irq;
>  	up.port.break_ctl = mxpcie8250_break_ctl;
>  
> -	for (unsigned int i = 0; i < num_ports; i++) {
> +	for (i = 0; i < num_ports; i++) {
>  		mxpcie8250_setup_port(pdev, priv, &up, i);
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

[Severity: High]
This is a pre-existing issue, but does mxpcie8250_setup_port() fail to set
up.port.port_id?

Because up.port.port_id is not initialized for individual serial ports during
probe, all successfully registered ports seem to incorrectly share port_id = 0.

Could this lead to configuration meant for other ports silently overwriting
port 0's hardware registers and software state?

For example, when setting RX trigger levels or handling ioctls for RS485
(TIOCSRS485) on any non-zero port, it looks like port->port_id will evaluate
to 0 in mxpcie8250_rs485_config():

drivers/tty/serial/8250/8250_mxpcie.c:mxpcie8250_rs485_config() {
	...
	mxpcie8250_set_interface(priv, port->port_id, mode);
	...
}

causing the driver to incorrectly read, modify, and write the configuration of
port 0 instead of the target port.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260901041519.114737-1-lilinmao@kylinos.cn?part=2

  reply	other threads:[~2026-09-01  4:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01  4:15 [PATCH v2 0/3] serial: 8250_mxpcie: probe and console fixes Linmao Li
2026-09-01  4:15 ` [PATCH v2 1/3] serial: 8250_mxpcie: set the driver data before registering ports Linmao Li
2026-09-01  4:32   ` sashiko-bot
2026-09-01  5:31     ` Jiri Slaby
2026-09-01  4:15 ` [PATCH v2 2/3] serial: 8250_mxpcie: only unregister the ports that were registered Linmao Li
2026-09-01  4:27   ` sashiko-bot [this message]
2026-09-01  9:00   ` Andy Shevchenko
2026-09-01  4:15 ` [PATCH v2 3/3] serial: 8250_mxpcie: take the line settings from the new termios Linmao Li
2026-09-01  4:23   ` sashiko-bot
2026-09-01  5:33     ` Jiri Slaby
2026-09-01  9:01 ` [PATCH v2 0/3] serial: 8250_mxpcie: probe and console fixes Andy Shevchenko
2026-09-02  2:22 ` Crescent Hsieh

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=20260901042749.AF29A1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=lilinmao@kylinos.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