All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: proximity: srf04: fix runtime PM autosuspend cleanup
@ 2026-08-07 14:19 Guangshuo Li
  2026-08-07 15:02 ` Joshua Crofts
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Guangshuo Li @ 2026-08-07 14:19 UTC (permalink / raw)
  To: Andreas Klinger, Jonathan Cameron, David Lechner, Nuno Sá,
	Andy Shevchenko, linux-iio, linux-kernel
  Cc: Guangshuo Li

srf04_probe() calls pm_runtime_use_autosuspend() when the optional
power GPIO is present, but srf04_remove() does not call the matching
pm_runtime_dont_use_autosuspend() before disabling runtime PM.

The runtime PM documentation requires pm_runtime_use_autosuspend() to
be balanced with pm_runtime_dont_use_autosuspend() when the driver is
removed. Failing to do so can leave the autosuspend usage state
unbalanced and may result in a usage_count leak when the autosuspend
delay is negative.

Add the missing pm_runtime_dont_use_autosuspend() call in the remove
path before disabling runtime PM.

This issue was found by manual code inspection.

Fixes: 2251157b335b4 ("iio: srf04: add power management feature")
Signed-off-by: Guangshuo Li <lgs201920130244@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 7be50bdebfcb..5f270f506803 100644
--- a/drivers/iio/proximity/srf04.c
+++ b/drivers/iio/proximity/srf04.c
@@ -347,6 +347,7 @@ static void srf04_remove(struct platform_device *pdev)
 	iio_device_unregister(indio_dev);
 
 	if (data->gpiod_power) {
+		pm_runtime_dont_use_autosuspend(data->dev);
 		pm_runtime_disable(data->dev);
 		pm_runtime_set_suspended(data->dev);
 	}
-- 
2.43.0


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

end of thread, other threads:[~2026-08-24 12:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-07 14:19 [PATCH] iio: proximity: srf04: fix runtime PM autosuspend cleanup Guangshuo Li
2026-08-07 15:02 ` Joshua Crofts
2026-08-18  7:07   ` Johan Hovold
2026-08-07 23:41 ` Jonathan Cameron
2026-08-18  7:14 ` Johan Hovold
2026-08-22  0:08   ` Jonathan Cameron
2026-08-24 12:32     ` Johan Hovold

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.