From: Greg KH <gregkh@linuxfoundation.org>
To: Haotian Zhang <vulab@iscas.ac.cn>
Cc: jirislaby@kernel.org, ychuang3@nuvoton.com, schung@nuvoton.com,
linux-serial@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] serial: ma35d1: Fix resource leaks on driver removal
Date: Fri, 31 Oct 2025 17:31:32 +0100 [thread overview]
Message-ID: <2025103115-humped-body-d522@gregkh> (raw)
In-Reply-To: <20251029080039.1010-1-vulab@iscas.ac.cn>
On Wed, Oct 29, 2025 at 04:00:39PM +0800, Haotian Zhang wrote:
> 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);
You are doing two different things in this patch, shouldn't this be 2
different commits?
thanks,
greg k-h
prev parent reply other threads:[~2025-10-31 16:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2025103115-humped-body-d522@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=schung@nuvoton.com \
--cc=vulab@iscas.ac.cn \
--cc=ychuang3@nuvoton.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).