From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Arina Kharlamova via B4 Relay
<devnull+arina.kharlamova.mbzuai.ac.ae@kernel.org>
Cc: "Pali Rohár" <pali@kernel.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Jiri Slaby" <jirislaby@kernel.org>,
"Gregory CLEMENT" <gregory.clement@bootlin.com>,
"Wilson Ding" <dingwei@marvell.com>,
arina.kharlamova@mbzuai.ac.ae, linux-kernel@vger.kernel.org,
linux-serial@vger.kernel.org
Subject: Re: [PATCH v2] serial: mvebu-uart: do not leave a stale port behind when probe fails
Date: Thu, 03 Dec 2026 12:39:23 +0100 [thread overview]
Message-ID: <87a4mmioes.fsf@bootlin.com> (raw)
In-Reply-To: <20261203-v08b-v2-1-79564cfdbb46@mbzuai.ac.ae> (Arina Kharlamova via's message of "Thu, 03 Dec 2026 15:11:44 +0400")
On 03/12/2026 at 15:11:44 +04, Arina Kharlamova via B4 Relay <devnull+arina.kharlamova.mbzuai.ac.ae@kernel.org> wrote:
> From: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
>
> mvebu_uart_probe() fills the static mvebu_uart_ports[] entry with the
> devm mapping and the devm private data before it gets the clock and
> the interrupts, and keeps them if uart_add_one_port() fails. On any of
> these failures devres unmaps the registers and frees the private data,
> but the static port keeps membase, mapbase and private_data.
>
> mvebu_uart_console_setup() only checks membase and mapbase. When
> another port registers the console first, for example with
> console=ttyMV1 and ttyMV1 still waiting for its clock, the setup
> callback uses the stale port, accesses the unmapped registers and
> dereferences the freed private data.
>
> Keep the mapping in a local variable, test is_ext through mvuart
> instead of the port, and store membase, mapbase and private_data in
> the port only after the last step that can fail before
> uart_add_one_port(). Clear them again if uart_add_one_port() fails.
>
> Fixes: 30530791a7a0 ("serial: mvebu-uart: initial support for Armada-3700 serial port")
> Signed-off-by: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
> ---
> The static port array keeps pointers into devm memory after a failed
> or deferred probe. This patch moves the assignment of membase, mapbase
> and private_data after the clock and the interrupts and clears them
> when uart_add_one_port() fails. It is independent of my earlier clock
> patch for this driver; both add the same ret variable, so the one
> applied second needs git am -3.
>
> I noticed this while working on "serial: mvebu-uart: disable the clock
> when probe fails":
> https://lore.kernel.org/r/20261129-s2p-v08-v1-1-342b7170e692@mbzuai.ac.ae
> The Sashiko review pointed at it. With the help of an AI coding
> assistant (Claude); I reviewed the analysis and the fix.
> Compile-tested only, not tested on hardware.
> ---
> Changes in v2:
> - Set private_data after the clock and the interrupts too, and clear
> membase, mapbase and private_data when uart_add_one_port() fails
> (Sashiko review).
> - Fixes: point at the commit that added the uart_add_one_port() path.
> - Drop the Reviewed-by from Miquel Raynal, the patch changed.
Not sure it changed enough to drop it.
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
next prev parent reply other threads:[~2026-12-03 11:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 11:11 [PATCH v2] serial: mvebu-uart: do not leave a stale port behind when probe fails Arina Kharlamova
2026-12-03 11:11 ` Arina Kharlamova via B4 Relay
2026-12-03 11:27 ` sashiko-bot
2026-12-03 11:39 ` Miquel Raynal [this message]
2026-12-04 9:03 ` Greg Kroah-Hartman
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=87a4mmioes.fsf@bootlin.com \
--to=miquel.raynal@bootlin.com \
--cc=arina.kharlamova@mbzuai.ac.ae \
--cc=devnull+arina.kharlamova.mbzuai.ac.ae@kernel.org \
--cc=dingwei@marvell.com \
--cc=gregkh@linuxfoundation.org \
--cc=gregory.clement@bootlin.com \
--cc=jirislaby@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=pali@kernel.org \
/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.