[PATCH 2/2] serial: uartlite: Undo clock and runtime PM setup on probe failure

Arina Kharlamova via B4 Relay devnull+arina.kharlamova.mbzuai.ac.ae at kernel.org
Tue Dec 1 11:17:52 PST 2026


From: Arina Kharlamova <arina.kharlamova at mbzuai.ac.ae>

ulite_probe() enables the clock with clk_prepare_enable() and enables
runtime PM before it calls ulite_assign(). If ulite_assign() fails,
for example because the port number is not below ULITE_NR_UARTS, probe
only drops its usage count and returns the error. The clock is left
prepared and enabled and runtime PM is left enabled. A later probe of
the same device then calls pm_runtime_enable() again and gets the
"Unbalanced pm_runtime_enable!" warning.

When ulite_assign() fails, disable runtime PM, drop the usage count
without idling the device and disable and unprepare the clock.

Fixes: 14288befeb57 ("tty: serial: uartlite: Add clock adaptation")
Fixes: 5bbe10a6942d ("tty: serial: uartlite: Add runtime pm support")
Signed-off-by: Arina Kharlamova <arina.kharlamova at mbzuai.ac.ae>
---
 drivers/tty/serial/uartlite.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
index b9a14dc2f2fd..d2dfdfde72a2 100644
--- a/drivers/tty/serial/uartlite.c
+++ b/drivers/tty/serial/uartlite.c
@@ -881,6 +881,13 @@ of_err:
 	pm_runtime_enable(&pdev->dev);
 
 	ret = ulite_assign(&pdev->dev, id, res->start, irq, pdata);
+	if (ret) {
+		pm_runtime_disable(&pdev->dev);
+		pm_runtime_set_suspended(&pdev->dev);
+		pm_runtime_put_noidle(&pdev->dev);
+		clk_disable_unprepare(pdata->clk);
+		return ret;
+	}
 
 	pm_runtime_mark_last_busy(&pdev->dev);
 	pm_runtime_put_autosuspend(&pdev->dev);

-- 
Git-157)





More information about the linux-arm-kernel mailing list