From: sashiko-bot@kernel.org
To: "Arina Kharlamova" <arina.kharlamova@mbzuai.ac.ae>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH] serial: mvebu-uart: do not leave a stale port behind when probe fails
Date: Tue, 01 Dec 2026 19:30:14 +0000 [thread overview]
Message-ID: <sashiko-outbox-244073@kernel.org> (raw)
In-Reply-To: <20261201-v08b-v1-1-add40eb9ffee@mbzuai.ac.ae>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] serial: mvebu-uart: stale port pointers left on
mvebu_uart_probe() failure
--
commit d1e6578bd1896e971560b8acbf90f40f07f54907
Author: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
serial: mvebu-uart: do not leave a stale port behind when probe fails
This commit defers storing membase and mapbase in the static
mvebu_uart_ports[] entry until after clock and interrupt acquisition in
mvebu_uart_probe().
> diff --git a/drivers/tty/serial/mvebu-uart.c b/drivers/tty/serial/mvebu-uart.c
> index 8a61517d81f21..9f59fa5a706e0 100644
> --- a/drivers/tty/serial/mvebu-uart.c
> +++ b/drivers/tty/serial/mvebu-uart.c
> @@ -868,6 +868,7 @@ static int mvebu_uart_probe(struct platform_device *pdev)
> {
> const struct of_device_id *match = of_match_device(mvebu_uart_of_match,
> &pdev->dev);
> + void __iomem *base;
> struct uart_port *port;
> struct mvebu_uart *mvuart;
> struct resource *reg;
> @@ -908,10 +909,9 @@ static int mvebu_uart_probe(struct platform_device *pdev)
> port->irq = 0;
> port->irqflags = 0;
>
> - port->membase = devm_platform_get_and_ioremap_resource(pdev, 0, ®);
> - if (IS_ERR(port->membase))
> - return PTR_ERR(port->membase);
> - port->mapbase = reg->start;
> + base = devm_platform_get_and_ioremap_resource(pdev, 0, ®);
> + if (IS_ERR(base))
> + return PTR_ERR(base);
>
> mvuart = devm_kzalloc_obj(&pdev->dev, struct mvebu_uart);
> if (!mvuart)
> @@ -966,6 +966,9 @@ static int mvebu_uart_probe(struct platform_device *pdev)
> mvuart->irq[UART_TX_IRQ] = irq;
> }
>
> + port->membase = base;
> + port->mapbase = reg->start;
[Severity: Medium]
Can mvebu_uart_probe() still leave stale pointers in mvebu_uart_ports[] if
uart_add_one_port() fails, or leave a dangling port->private_data if
clock or IRQ acquisition fails?
If uart_add_one_port() returns an error before configuring the console,
devres unmaps base and frees mvuart while port->membase, port->mapbase and
port->private_data remain set in the static mvebu_uart_ports[] array. If
another port later registers the console, mvebu_uart_console_setup() sees
non-zero mapbase and membase and calls uart_set_options() ->
mvebu_uart_set_termios(), causing a use-after-free on port->private_data
and an access to unmapped MMIO at port->membase.
In addition, port->private_data = mvuart is still assigned before
devm_clk_get() and platform_get_irq(), so a clock or interrupt deferral
still leaves a dangling private_data pointer in mvebu_uart_ports[].
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201-v08b-v1-1-add40eb9ffee@mbzuai.ac.ae?part=1
prev parent reply other threads:[~2026-12-01 19:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 19:19 [PATCH] serial: mvebu-uart: do not leave a stale port behind when probe fails Arina Kharlamova
2026-12-01 19:19 ` Arina Kharlamova via B4 Relay
2026-12-01 19:30 ` 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-244073@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=arina.kharlamova@mbzuai.ac.ae \
--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.