serial: 8250_uniphier: Disable clock on probe error path
Subsystems (2)
PATCH 1/1 serial: 8250_uniphier: Disable clock on probe error path
uniphier_uart_probe() calls clk_prepare_enable() on priv->clk before it reads the port properties, but returns directly when uart_read_port_properties() fails, leaving the clock prepared and enabled.
The intent is clear from the surrounding code: the next error path, when serial8250_register_8250_port() fails, calls clk_disable_unprepare(), as does uniphier_uart_remove(). Add the missing call so the early failure behaves the same way.
Found by smatch:
drivers/tty/serial/8250/8250_uniphier.c:232 uniphier_uart_probe() warn: 'priv->clk' from clk_prepare_enable() not released on lines: 205.
--- drivers/tty/serial/8250/8250_uniphier.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/tty/serial/8250/8250_uniphier.c +3 -1
@@ -201,8 +201,10 @@ static int uniphier_uart_probe(struct platform_device *pdev) up.port.membase = membase; ret =uart_read_port_properties (&up.port); -if (ret) +if (ret) { +clk_disable_unprepare (priv->clk);return ret; + } up.port.type =PORT_16550A ; up.port.iotype =UPIO_MEM32 ;
Signature · 1 line
2.43.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 10 lines
uniphier_uart_probe()callsclk_prepare_enable()onpriv->clkbefore it reads the port properties, but returns directly whenuart_read_port_properties()fails, leaving the clock prepared and enabled.The intent is clear from the surrounding code: the next error path, when
serial8250_register_8250_port()fails, callsclk_disable_unprepare(), as doesuniphier_uart_remove(). Add the missing call so the early failure behaves the same way.
Quoted 6 lines
Found by smatch:
drivers/tty/serial/8250/8250_uniphier.c:232uniphier_uart_probe()warn: 'priv->clk' fromclk_prepare_enable()not released on lines: 205.Fixes 26e8349c0d76 ("serial: 8250_uniphier: Switch to use uart_read_port_properties()")Signed-off-by Malathi A <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 5 lines · Malathi A
uniphier_uart_probe()callsclk_prepare_enable()onpriv->clkbefore it reads the port properties, but returns directly whenuart_read_port_properties()fails, leaving the clock prepared and enabled.
Quoted 8 lines
The intent is clear from the surrounding code: the next error path, when
serial8250_register_8250_port()fails, callsclk_disable_unprepare(), as doesuniphier_uart_remove(). Add the missing call so the early failure behaves the same way.Found by smatch:
drivers/tty/serial/8250/8250_uniphier.c:232uniphier_uart_probe()warn: 'priv->clk' fromclk_prepare_enable()not released on lines: 205.
Why not using devm_clk_get_enabled() instead?
Signature · 2 lines
With Best Regards, Andy Shevchenko