* [PATCH] counter: ti-eqep: fix runtime PM leak in probe error path
@ 2026-04-17 15:06 Felix Gu
2026-04-17 15:20 ` David Lechner
0 siblings, 1 reply; 2+ messages in thread
From: Felix Gu @ 2026-04-17 15:06 UTC (permalink / raw)
To: David Lechner, William Breathitt Gray, Judith Mendez
Cc: linux-iio, linux-kernel, Felix Gu
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)
pm_runtime_get_sync(dev);
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);
- 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)
---
base-commit: 452c3b1ea875276105ac90ba474f72b4cd9b77a2
change-id: 20260417-ti-eqep-8efb9cc713ea
Best regards,
--
Felix Gu <ustc.gu@gmail.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] counter: ti-eqep: fix runtime PM leak in probe error path
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
0 siblings, 0 replies; 2+ messages in thread
From: David Lechner @ 2026-04-17 15:20 UTC (permalink / raw)
To: Felix Gu, William Breathitt Gray, Judith Mendez
Cc: linux-iio, linux-kernel, Linux PM
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,
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-17 15:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox