mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iio: srf04: fix pm_runtime handling on probe error path
@ 2026-07-27 15:51 Cong Nguyen
  2026-08-01  2:55 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Cong Nguyen @ 2026-07-27 15:51 UTC (permalink / raw)
  To: Andreas Klinger, Jonathan Cameron
  Cc: David Lechner, Nuno Sá, Andy Shevchenko, linux-iio, linux-kernel

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>
---
 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);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] iio: srf04: fix pm_runtime handling on probe error path
  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
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2026-08-01  2:55 UTC (permalink / raw)
  To: Cong Nguyen
  Cc: Andreas Klinger, David Lechner, Nuno Sá,
	Andy Shevchenko, linux-iio, linux-kernel

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);


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-01  2:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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®