Re: [PATCH v2] counter: ti-eqep: balance pm_runtime on devm_clk_get_enabled() failure
From: William Breathitt Gray
Date: Wed May 27 2026 - 04:19:14 EST
On Wed, May 27, 2026 at 10:10:20AM +0200, Andy Shevchenko wrote:
> On Mon, May 25, 2026 at 5:21 PM Stepan Ionichev <sozdayvek@xxxxxxxxx> wrote:
> >
> > ti_eqep_probe() calls pm_runtime_enable() and pm_runtime_get_sync()
> > before devm_clk_get_enabled(). If the clk call fails, the function
> > returns directly via dev_err_probe(), leaving runtime PM enabled
> > and the usage counter incremented.
> >
> > Route the clk error through the same err_pm cleanup as counter_add()
> > so the runtime PM state is unwound on every failure path.
>
> ...
>
> > 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 err_pm;
>
> This is not right. The devm_*() should not be followed by goto.
>
> > + }
>
> ...
>
> > +err_pm:
> > + pm_runtime_put_sync(dev);
> > + pm_runtime_disable(dev);
> > + return err;
>
> You have to use the respective devm_pm_*() at the same time.
>
> ...
>
> William, this patch should not be applied (or should be reverted) as
> in current form it replaces one issue by another.
>
> --
> With Best Regards,
> Andy Shevchenko
I'll revert for now. Would the proper fix be to replace all
pm_runtime_*() with their respective devm_pm_*() calls?
William Breathitt Gray