Re: [PATCH v2] serial: mvebu-uart: do not leave a stale port behind when probe fails

From: Greg Kroah-Hartman

Date: Fri Dec 04 2026 - 04:10:40 EST


On Thu, Dec 03, 2026 at 03:11:44PM +0400, Arina Kharlamova via B4 Relay wrote:
> From: Arina Kharlamova <arina.kharlamova@xxxxxxxxxxxx>
>
> 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@xxxxxxxxxxxx>
> ---

Does not apply to the tty-next branch. Can you rebase and resend?

thanks,

greg k-h