mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: William Breathitt Gray <wbg@kernel.org>
To: phucduc.bui@gmail.com
Cc: William Breathitt Gray <wbg@kernel.org>,
	David Lechner <david@lechnology.com>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] counter: ti-eqep: Fix runtime PM error handling in probe
Date: Sat, 31 Oct 2026 12:45:50 -0400	[thread overview]
Message-ID: <20261031164551.3637340-1-wbg@kernel.org> (raw)
In-Reply-To: <20260922032146.321006-1-phucduc.bui@gmail.com>

On Tue, Sep 22, 2026 at 10:21:46AM +0700, phucduc.bui@gmail.com wrote:
> From: bui duc phuc <phucduc.bui@gmail.com>
> 
> pm_runtime_get_sync() errors were not checked, and if
> devm_clk_get_enabled() failed afterwards, the function returned without
> calling pm_runtime_put_sync()/pm_runtime_disable(), leaking the runtime PM
> usage count.
> 
> Switch to pm_runtime_resume_and_get() and add proper error unwinding via
> goto labels so every failure path after pm_runtime_enable() is cleaned up
> correctly.
> 
> Fixes: f213729f6796 ("counter: new TI eQEP driver")
> Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>

Hello,

This patch looks similar to another we're considering for ti-eqep.[^1]
Perhaps you can provide a review or comment in that discussion thread so
we can address this issue together.

William Breathitt Gray

[^1]: https://lore.kernel.org/all/20260529095834.2561-1-sozdayvek@gmail.com/

> ---
>  drivers/counter/ti-eqep.c | 27 +++++++++++++++++++--------
>  1 file changed, 19 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/counter/ti-eqep.c b/drivers/counter/ti-eqep.c
> index 0dda3f2b14c7..698a9920f20d 100644
> --- a/drivers/counter/ti-eqep.c
> +++ b/drivers/counter/ti-eqep.c
> @@ -544,20 +544,31 @@ static int ti_eqep_probe(struct platform_device *pdev)
>  	 * domain.
>  	 */
>  	pm_runtime_enable(dev);
> -	pm_runtime_get_sync(dev);
> +	err = pm_runtime_resume_and_get(dev);
> +	if (err < 0) {
> +		dev_err_probe(dev, err, "failed to enable runtime PM\n");
> +		goto err_runtime_disable;
> +	}
> 
>  	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 = PTR_ERR(clk);
> +		dev_err_probe(dev, err, "failed to enable clock\n");
> +		goto err_runtime_put;
> +	}
> 
>  	err = counter_add(counter);
> -	if (err < 0) {
> -		pm_runtime_put_sync(dev);
> -		pm_runtime_disable(dev);
> -		return err;
> -	}
> +	if (err < 0)
> +		goto err_runtime_put;
> 
>  	return 0;
> +
> +err_runtime_put:
> +	pm_runtime_put_sync(dev);
> +err_runtime_disable:
> +	pm_runtime_disable(dev);
> +
> +	return err;
>  }
> 
>  static void ti_eqep_remove(struct platform_device *pdev)
> --
> 2.43.0
> 

      reply	other threads:[~2026-10-31 16:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22  3:21 phucduc.bui
2026-10-31 16:45 ` William Breathitt Gray [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=20261031164551.3637340-1-wbg@kernel.org \
    --to=wbg@kernel.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=david@lechnology.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=phucduc.bui@gmail.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

all inboxes | Powered by JetHome®