From: Yu Tu <yu.tu@amlogic.com>
To: <linux-serial@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-amlogic@lists.infradead.org>,
<linux-kernel@vger.kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>,
Neil Armstrong <narmstrong@baylibre.com>,
Kevin Hilman <khilman@baylibre.com>,
Jerome Brunet <jbrunet@baylibre.com>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
Yu Tu <yu.tu@amlogic.com>, kernel test robot <lkp@intel.com>,
Dan Carpenter <dan.carpenter@oracle.com>
Subject: [PATCH] tty: serial: meson: Fixed an issue where pclk was turned on on probe but should be turned off on subsequent errors.
Date: Tue, 1 Mar 2022 13:37:38 +0800 [thread overview]
Message-ID: <20220301053738.21163-1-yu.tu@amlogic.com> (raw)
Call clk_prepare_enable in the probe function to enable pclk. If you
exit the probe function later in an error, call clk_disable_unprepare
to disable pclk.
Fixes: 44023b8e1f14 ("tty: serial:meson: Describes the calculation of the UART baud rate clock using a clock frame“)
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Yu Tu <yu.tu@amlogic.com>
---
drivers/tty/serial/meson_uart.c | 37 +++++++++++++++++++++++----------
1 file changed, 26 insertions(+), 11 deletions(-)
diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c
index bf6be5468aaf..972f210f3492 100644
--- a/drivers/tty/serial/meson_uart.c
+++ b/drivers/tty/serial/meson_uart.c
@@ -780,28 +780,37 @@ static int meson_uart_probe(struct platform_device *pdev)
return ret;
irq = platform_get_irq(pdev, 0);
- if (irq < 0)
- return irq;
+ if (irq < 0) {
+ ret = irq;
+ goto err_out_clk_disable;
+ }
of_property_read_u32(pdev->dev.of_node, "fifo-size", &fifosize);
if (meson_ports[pdev->id]) {
dev_err(&pdev->dev, "port %d already allocated\n", pdev->id);
- return -EBUSY;
+ ret = -EBUSY;
+ goto err_out_clk_disable;
}
port = devm_kzalloc(&pdev->dev, sizeof(struct uart_port), GFP_KERNEL);
- if (!port)
- return -ENOMEM;
+ if (!port) {
+ ret = -ENOMEM;
+ goto err_out_clk_disable;
+ }
port->membase = devm_ioremap_resource(&pdev->dev, res_mem);
- if (IS_ERR(port->membase))
- return PTR_ERR(port->membase);
+ if (IS_ERR(port->membase)) {
+ ret = PTR_ERR(port->membase);
+ goto err_out_clk_disable;
+ }
private_data = devm_kzalloc(&pdev->dev, sizeof(*private_data),
GFP_KERNEL);
- if (!private_data)
- return -ENOMEM;
+ if (!private_data) {
+ ret = -ENOMEM;
+ goto err_out_clk_disable;
+ }
if (device_get_match_data(&pdev->dev))
private_data->use_xtal_clk = true;
@@ -822,7 +831,7 @@ static int meson_uart_probe(struct platform_device *pdev)
ret = meson_uart_probe_clocks(port);
if (ret)
- return ret;
+ goto err_out_clk_disable;
meson_ports[pdev->id] = port;
platform_set_drvdata(pdev, port);
@@ -831,9 +840,15 @@ static int meson_uart_probe(struct platform_device *pdev)
meson_uart_reset(port);
ret = uart_add_one_port(&meson_uart_driver, port);
- if (ret)
+ if (ret) {
meson_ports[pdev->id] = NULL;
+ goto err_out_clk_disable;
+ }
+
+ return 0;
+err_out_clk_disable:
+ clk_disable_unprepare(pclk);
return ret;
}
base-commit: d4ab5487cc77a4053dc9070c5761ad94bf397825
--
2.33.1
reply other threads:[~2022-03-01 5:38 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220301053738.21163-1-yu.tu@amlogic.com \
--to=yu.tu@amlogic.com \
--cc=dan.carpenter@oracle.com \
--cc=gregkh@linuxfoundation.org \
--cc=jbrunet@baylibre.com \
--cc=jirislaby@kernel.org \
--cc=khilman@baylibre.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=lkp@intel.com \
--cc=martin.blumenstingl@googlemail.com \
--cc=narmstrong@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 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).