[PATCH] serial: mvebu-uart: disable the clock when probe fails

From: Arina Kharlamova via B4 Relay

Date: Sun Nov 29 2026 - 02:28:28 EST


From: Arina Kharlamova <arina.kharlamova@xxxxxxxxxxxx>

mvebu_uart_probe() prepares and enables the UART clock, but the later
returns for a missing interrupt, including -EPROBE_DEFER from
platform_get_irq(), and for a failed uart_add_one_port() leave it
enabled. The clock comes from devm_clk_get(), so devres only puts it,
and every deferred probe raises the enable count by one more.

Disable and unprepare the clock through a devres action registered
right after it is enabled.

Fixes: 68a0db1d7da2 ("serial: mvebu-uart: add function to change baudrate")
Signed-off-by: Arina Kharlamova <arina.kharlamova@xxxxxxxxxxxx>
---
Found by the spec2patch formal prover, with the help of an AI coding
assistant (Claude); I reviewed the analysis and the fix.
---
drivers/tty/serial/mvebu-uart.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/mvebu-uart.c b/drivers/tty/serial/mvebu-uart.c
index 8a61517d81f2..d344ad2023a3 100644
--- a/drivers/tty/serial/mvebu-uart.c
+++ b/drivers/tty/serial/mvebu-uart.c
@@ -864,6 +864,11 @@ static const struct of_device_id mvebu_uart_of_match[];
/* Counter to keep track of each UART port id when not using CONFIG_OF */
static int uart_num_counter;

+static void mvebu_uart_clk_disable(void *data)
+{
+ clk_disable_unprepare(data);
+}
+
static int mvebu_uart_probe(struct platform_device *pdev)
{
const struct of_device_id *match = of_match_device(mvebu_uart_of_match,
@@ -871,7 +876,7 @@ static int mvebu_uart_probe(struct platform_device *pdev)
struct uart_port *port;
struct mvebu_uart *mvuart;
struct resource *reg;
- int id, irq;
+ int id, irq, ret;

/* Assume that all UART ports have a DT alias or none has */
id = of_alias_get_id(pdev->dev.of_node, "serial");
@@ -935,8 +940,14 @@ static int mvebu_uart_probe(struct platform_device *pdev)
return PTR_ERR(mvuart->clk);
}
} else {
- if (!clk_prepare_enable(mvuart->clk))
+ if (!clk_prepare_enable(mvuart->clk)) {
+ ret = devm_add_action_or_reset(&pdev->dev,
+ mvebu_uart_clk_disable,
+ mvuart->clk);
+ if (ret)
+ return ret;
port->uartclk = clk_get_rate(mvuart->clk);
+ }
}

/* Manage interrupts */

---
base-commit: 25faec9ce61c01fb45abf812a222c5b43c3cd5c5
change-id: 20261129-s2p-v08-290368f48291

Best regards,
--
Arina Kharlamova <arina.kharlamova@xxxxxxxxxxxx>