From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
To: Vitalii Mordan <mordan@ispras.ru>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Jiri Slaby" <jirislaby@kernel.org>,
"Andreas Färber" <afaerber@suse.de>,
"Jeff Johnson" <quic_jjohnson@quicinc.com>,
"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
"Amit Singh Tomar" <amittomer25@gmail.com>,
linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-actions@lists.infradead.org,
"Fedor Pchelkin" <pchelkin@ispras.ru>,
"Alexey Khoroshilov" <khoroshilov@ispras.ru>,
"Vadim Mutilin" <mutilin@ispras.ru>,
lvc-project@linuxtesting.org, stable@vger.kernel.org
Subject: Re: [PATCH] tty: owl-uart: fix call balance of owl_port->clk handling routines
Date: Fri, 14 Feb 2025 22:44:05 +0530 [thread overview]
Message-ID: <20250214171405.kvyyespxtfqxhapc@thinkpad> (raw)
In-Reply-To: <20250213112416.1610678-1-mordan@ispras.ru>
On Thu, Feb 13, 2025 at 02:24:16PM +0300, Vitalii Mordan wrote:
> If owl_port->clk was enabled in owl_uart_probe(), it must be disabled in
> all error paths to ensure proper cleanup. However, if uart_add_one_port()
> returns an error in owl_uart_probe(), the owl_port->clk clock will not be
> disabled.
>
> Use the devm_clk_get_enabled() helper function to ensure proper call
> balance for owl_port->clk.
>
Do not use newly introduced APIs to fix old bugs. The bug should be fixed
separately to allow backporting and the conversion should be done on top.
- Mani
> Found by Linux Verification Center (linuxtesting.org) with Klever.
>
> Fixes: abf42d2f333b ("tty: serial: owl: add "much needed" clk_prepare_enable()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Vitalii Mordan <mordan@ispras.ru>
> ---
> drivers/tty/serial/owl-uart.c | 12 ++----------
> 1 file changed, 2 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/tty/serial/owl-uart.c b/drivers/tty/serial/owl-uart.c
> index 0542882cfbbe..64446820437c 100644
> --- a/drivers/tty/serial/owl-uart.c
> +++ b/drivers/tty/serial/owl-uart.c
> @@ -680,18 +680,12 @@ static int owl_uart_probe(struct platform_device *pdev)
> if (!owl_port)
> return -ENOMEM;
>
> - owl_port->clk = devm_clk_get(&pdev->dev, NULL);
> + owl_port->clk = devm_clk_get_enabled(&pdev->dev, NULL);
> if (IS_ERR(owl_port->clk)) {
> - dev_err(&pdev->dev, "could not get clk\n");
> + dev_err(&pdev->dev, "could not get and enable clk\n");
> return PTR_ERR(owl_port->clk);
> }
>
> - ret = clk_prepare_enable(owl_port->clk);
> - if (ret) {
> - dev_err(&pdev->dev, "could not enable clk\n");
> - return ret;
> - }
> -
> owl_port->port.dev = &pdev->dev;
> owl_port->port.line = pdev->id;
> owl_port->port.type = PORT_OWL;
> @@ -701,7 +695,6 @@ static int owl_uart_probe(struct platform_device *pdev)
> owl_port->port.uartclk = clk_get_rate(owl_port->clk);
> if (owl_port->port.uartclk == 0) {
> dev_err(&pdev->dev, "clock rate is zero\n");
> - clk_disable_unprepare(owl_port->clk);
> return -EINVAL;
> }
> owl_port->port.flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_LOW_LATENCY;
> @@ -725,7 +718,6 @@ static void owl_uart_remove(struct platform_device *pdev)
>
> uart_remove_one_port(&owl_uart_driver, &owl_port->port);
> owl_uart_ports[pdev->id] = NULL;
> - clk_disable_unprepare(owl_port->clk);
> }
>
> static struct platform_driver owl_uart_platform_driver = {
> --
> 2.25.1
>
--
மணிவண்ணன் சதாசிவம்
next prev parent reply other threads:[~2025-02-14 17:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-13 11:24 [PATCH] tty: owl-uart: fix call balance of owl_port->clk handling routines Vitalii Mordan
2025-02-14 17:14 ` Manivannan Sadhasivam [this message]
2025-02-14 18:39 ` Fedor Pchelkin
2025-02-19 17:48 ` Manivannan Sadhasivam
2025-02-19 17:49 ` Manivannan Sadhasivam
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=20250214171405.kvyyespxtfqxhapc@thinkpad \
--to=manivannan.sadhasivam@linaro.org \
--cc=afaerber@suse.de \
--cc=amittomer25@gmail.com \
--cc=bigeasy@linutronix.de \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=khoroshilov@ispras.ru \
--cc=linux-actions@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=mordan@ispras.ru \
--cc=mutilin@ispras.ru \
--cc=pchelkin@ispras.ru \
--cc=quic_jjohnson@quicinc.com \
--cc=stable@vger.kernel.org \
--cc=u.kleine-koenig@baylibre.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.