From: David Lechner <david@lechnology.com>
To: Felix Gu <ustc.gu@gmail.com>,
William Breathitt Gray <wbg@kernel.org>,
Judith Mendez <jm@ti.com>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
Linux PM <linux-pm@vger.kernel.org>
Subject: Re: [PATCH] counter: ti-eqep: fix runtime PM leak in probe error path
Date: Fri, 17 Apr 2026 10:20:11 -0500 [thread overview]
Message-ID: <54fe62e2-2134-4ea4-96ae-4534c559dbe4@lechnology.com> (raw)
In-Reply-To: <20260417-ti-eqep-v1-1-a7db4642d9d0@gmail.com>
My knowledge of pm_runtime is a bit lacking, so I would suggest
to include that mailing list on the CC to get more expert review.
On 4/17/26 10:06 AM, Felix Gu wrote:
> In ti_eqep_probe(), if devm_clk_get_enabled() fails, the function
> returns without cleaning up the runtime PM state.
>
> Fixes: 0cf81c73e4c6 ("counter: ti-eqep: enable clock at probe")
> Signed-off-by: Felix Gu <ustc.gu@gmail.com>
> ---
> drivers/counter/ti-eqep.c | 19 ++++++++++++-------
> 1 file changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/counter/ti-eqep.c b/drivers/counter/ti-eqep.c
> index d21c157e531a..dfa945b3eec6 100644
> --- a/drivers/counter/ti-eqep.c
> +++ b/drivers/counter/ti-eqep.c
> @@ -548,17 +548,22 @@ static int ti_eqep_probe(struct platform_device *pdev)
Can we use devm_pm_runtime_enable() to partially solve this?
> pm_runtime_get_sync(dev);
I don't think we should have non-devm stuff before devm stuff
so this needs to be moved later of have some kind of devm cleanup.
>
> clk = devm_clk_get_enabled(dev, NULL);
> - if (IS_ERR(clk))
> - return dev_err_probe(dev, PTR_ERR(clk), "failed to enable clock\n");
> + if (IS_ERR(clk)) {
> + err = dev_err_probe(dev, PTR_ERR(clk), "failed to enable clock\n");
> + goto disable_pm;
> + }
>
> err = counter_add(counter);
This can be changed to devm_counter_add().
> - if (err < 0) {
> - pm_runtime_put_sync(dev);
> - pm_runtime_disable(dev);
> - return err;
> - }
> + if (err < 0)
> + goto disable_pm;
>
> return 0;
> +
> +disable_pm:
> + pm_runtime_put_sync(dev);
> + pm_runtime_disable(dev);
> +
> + return err;
> }
>
> static void ti_eqep_remove(struct platform_device *pdev)
And once everything is converted to devm, we can drop the
remove callback.
>
> ---
> base-commit: 452c3b1ea875276105ac90ba474f72b4cd9b77a2
> change-id: 20260417-ti-eqep-8efb9cc713ea
>
> Best regards,
prev parent reply other threads:[~2026-04-17 15:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-17 15:06 [PATCH] counter: ti-eqep: fix runtime PM leak in probe error path Felix Gu
2026-04-17 15:20 ` David Lechner [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=54fe62e2-2134-4ea4-96ae-4534c559dbe4@lechnology.com \
--to=david@lechnology.com \
--cc=jm@ti.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=ustc.gu@gmail.com \
--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