From: Felix Gu <ustc.gu@gmail.com>
To: David Lechner <david@lechnology.com>,
William Breathitt Gray <wbg@kernel.org>,
Judith Mendez <jm@ti.com>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
Felix Gu <ustc.gu@gmail.com>
Subject: [PATCH v2] counter: ti-eqep: fix runtime PM leak in probe error path
Date: Sat, 18 Apr 2026 00:08:35 +0800 [thread overview]
Message-ID: <20260418-ti-eqep-v2-1-2f803963c4fc@gmail.com> (raw)
In ti_eqep_probe(), if devm_clk_get_enabled() fails, the function
returns without cleaning up the runtime PM state.
Switch to devm functions to fix the problem and remove unneeded
remove() callback.
Fixes: 0cf81c73e4c6 ("counter: ti-eqep: enable clock at probe")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
Changes in v2:
- Switch to devm functions to fix David's comment.
- Link to v1: https://lore.kernel.org/r/20260417-ti-eqep-v1-1-a7db4642d9d0@gmail.com
---
drivers/counter/ti-eqep.c | 33 +++++++++++++--------------------
1 file changed, 13 insertions(+), 20 deletions(-)
diff --git a/drivers/counter/ti-eqep.c b/drivers/counter/ti-eqep.c
index d21c157e531a..08dc6d0ad5e4 100644
--- a/drivers/counter/ti-eqep.c
+++ b/drivers/counter/ti-eqep.c
@@ -492,6 +492,11 @@ static const struct regmap_config ti_eqep_regmap16_config = {
.max_register = QCPRDLAT,
};
+static void pm_put_sync(void *data)
+{
+ pm_runtime_put_sync(data);
+}
+
static int ti_eqep_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -544,31 +549,20 @@ static int ti_eqep_probe(struct platform_device *pdev)
* parent PWMSS bus driver. On AM17xx, this comes from the PSC power
* domain.
*/
- pm_runtime_enable(dev);
+ err = devm_pm_runtime_enable(dev);
+ if (err)
+ return err;
+
pm_runtime_get_sync(dev);
+ err = devm_add_action_or_reset(dev, pm_put_sync, dev);
+ if (err)
+ return err;
clk = devm_clk_get_enabled(dev, NULL);
if (IS_ERR(clk))
return dev_err_probe(dev, PTR_ERR(clk), "failed to enable clock\n");
- err = counter_add(counter);
- if (err < 0) {
- pm_runtime_put_sync(dev);
- pm_runtime_disable(dev);
- return err;
- }
-
- return 0;
-}
-
-static void ti_eqep_remove(struct platform_device *pdev)
-{
- struct counter_device *counter = platform_get_drvdata(pdev);
- struct device *dev = &pdev->dev;
-
- counter_unregister(counter);
- pm_runtime_put_sync(dev);
- pm_runtime_disable(dev);
+ return devm_counter_add(dev, counter);
}
static const struct of_device_id ti_eqep_of_match[] = {
@@ -580,7 +574,6 @@ MODULE_DEVICE_TABLE(of, ti_eqep_of_match);
static struct platform_driver ti_eqep_driver = {
.probe = ti_eqep_probe,
- .remove = ti_eqep_remove,
.driver = {
.name = "ti-eqep-cnt",
.of_match_table = ti_eqep_of_match,
---
base-commit: 452c3b1ea875276105ac90ba474f72b4cd9b77a2
change-id: 20260417-ti-eqep-8efb9cc713ea
Best regards,
--
Felix Gu <ustc.gu@gmail.com>
reply other threads:[~2026-04-17 16:08 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=20260418-ti-eqep-v2-1-2f803963c4fc@gmail.com \
--to=ustc.gu@gmail.com \
--cc=david@lechnology.com \
--cc=jm@ti.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wbg@kernel.org \
/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