[PATCH] serial: ma35d1: Fix resource leaks on driver removal

Haotian Zhang vulab at iscas.ac.cn
Wed Oct 29 01:00:39 PDT 2025


The driver fails to release resources acquired during probe. It calls
of_clk_get() to obtain the clock reference but never calls clk_put()
in the remove path, leaking the clock reference count. Similarly, it
calls ioremap() to map UART registers but never calls iounmap() during
removal, leaking the I/O memory mapping.

Switch to devm_clk_get() for automatic clock resource management and
add iounmap() call in ma35d1serial_remove() to properly release the
memory mapping.

Fixes: 930cbf92db01 ("tty: serial: Add Nuvoton ma35d1 serial driver support")
Signed-off-by: Haotian Zhang <vulab at iscas.ac.cn>
---
 drivers/tty/serial/ma35d1_serial.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/ma35d1_serial.c b/drivers/tty/serial/ma35d1_serial.c
index 285b0fe41a86..37e9f6166290 100644
--- a/drivers/tty/serial/ma35d1_serial.c
+++ b/drivers/tty/serial/ma35d1_serial.c
@@ -711,7 +711,7 @@ static int ma35d1serial_probe(struct platform_device *pdev)
 
 	spin_lock_init(&up->port.lock);
 
-	up->clk = of_clk_get(pdev->dev.of_node, 0);
+	up->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(up->clk)) {
 		ret = PTR_ERR(up->clk);
 		dev_err(&pdev->dev, "failed to get core clk: %d\n", ret);
@@ -762,6 +762,7 @@ static void ma35d1serial_remove(struct platform_device *dev)
 
 	uart_remove_one_port(&ma35d1serial_reg, port);
 	clk_disable_unprepare(up->clk);
+	iounmap(up->port.membase);
 }
 
 static int ma35d1serial_suspend(struct platform_device *dev, pm_message_t state)
-- 
2.50.1.windows.1




More information about the linux-arm-kernel mailing list