[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251029080039.1010-1-vulab@iscas.ac.cn>
Date: Wed, 29 Oct 2025 16:00:39 +0800
From: Haotian Zhang <vulab@...as.ac.cn>
To: gregkh@...uxfoundation.org,
	jirislaby@...nel.org
Cc: ychuang3@...oton.com,
	schung@...oton.com,
	linux-serial@...r.kernel.org,
	linux-arm-kernel@...ts.infradead.org,
	linux-kernel@...r.kernel.org,
	Haotian Zhang <vulab@...as.ac.cn>
Subject: [PATCH] serial: ma35d1: Fix resource leaks on driver removal
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@...as.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
Powered by blists - more mailing lists
 
