linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] serial: ma35d1: Fix resource leaks on driver removal
@ 2025-10-29  8:00 Haotian Zhang
  2025-10-29 10:17 ` Greg KH
  2025-10-31 16:31 ` Greg KH
  0 siblings, 2 replies; 3+ messages in thread
From: Haotian Zhang @ 2025-10-29  8:00 UTC (permalink / raw)
  To: gregkh, jirislaby
  Cc: ychuang3, schung, linux-serial, linux-arm-kernel, linux-kernel,
	Haotian Zhang

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@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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-10-31 16:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-29  8:00 [PATCH] serial: ma35d1: Fix resource leaks on driver removal Haotian Zhang
2025-10-29 10:17 ` Greg KH
2025-10-31 16:31 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).