Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Cong Nguyen <congnt264@gmail.com>
Cc: "Andreas Klinger" <ak@it-klinger.de>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: srf04: fix pm_runtime handling on probe error path
Date: Sat, 1 Aug 2026 03:55:33 +0100	[thread overview]
Message-ID: <20260801035533.1a854a57@jic23-huawei> (raw)
In-Reply-To: <20260727155115.1855881-1-congnt264@gmail.com>

On Mon, 27 Jul 2026 22:51:15 +0700
Cong Nguyen <congnt264@gmail.com> wrote:

> When pm_runtime_set_active() fails during probe, the driver logs the
> error and unregisters the IIO device, but then falls through and still
> calls pm_runtime_enable() before returning the error.
> 
> Since probe returns an error, srf04_remove() is never called, so
> runtime PM is left enabled without a matching pm_runtime_disable().
> This leaks the enable and triggers an "Unbalanced pm_runtime_enable!"
> warning on a subsequent bind of the device.
> 
> Return the error right after unregistering the IIO device so that
> runtime PM is not enabled on the failure path.
> 
> Fixes: 2251157b335b ("iio: srf04: add power management feature")
> Cc: stable@vger.kernel.org
> Signed-off-by: Cong Nguyen <congnt264@gmail.com>
Applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan


> ---
>  drivers/iio/proximity/srf04.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/proximity/srf04.c b/drivers/iio/proximity/srf04.c
> index e97f9a20ac7a..337938657449 100644
> --- a/drivers/iio/proximity/srf04.c
> +++ b/drivers/iio/proximity/srf04.c
> @@ -331,6 +331,7 @@ static int srf04_probe(struct platform_device *pdev)
>  		if (ret) {
>  			dev_err(data->dev, "pm_runtime_set_active: %d\n", ret);
>  			iio_device_unregister(indio_dev);
> +			return ret;
>  		}
>  
>  		pm_runtime_enable(data->dev);


      reply	other threads:[~2026-08-01  2:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-27 15:51 [PATCH] iio: srf04: fix pm_runtime handling on probe error path Cong Nguyen
2026-08-01  2:55 ` Jonathan Cameron [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=20260801035533.1a854a57@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=ak@it-klinger.de \
    --cc=andy@kernel.org \
    --cc=congnt264@gmail.com \
    --cc=dlechner@baylibre.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.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