mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iio: light: gp2ap002: Fix runtime PM leak in gp2ap002_read_raw()
@ 2026-09-16 16:36 Wentao Liang
  2026-09-16 17:34 ` Linus Walleij
  0 siblings, 1 reply; 3+ messages in thread
From: Wentao Liang @ 2026-09-16 16:36 UTC (permalink / raw)
  To: andy
  Cc: dlechner, jic23, linusw, linux-iio, linux-kernel, nuno.sa,
	xc-racer2, Wentao Liang, stable

pm_runtime_get_sync() increments the usage counter even on failure,
so every successful call must be paired with a put. A failure of
gp2ap002_get_lux() returned early and skipped the paired
pm_runtime_put_autosuspend(), permanently preventing runtime
suspend. Jump to the common exit that releases the reference.

Fixes: f6dbf83c17cb ("iio: light: gp2ap002: Take runtime PM reference on light read")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/iio/light/gp2ap002.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/light/gp2ap002.c b/drivers/iio/light/gp2ap002.c
index a0d8a58f2704..886accf5e859 100644
--- a/drivers/iio/light/gp2ap002.c
+++ b/drivers/iio/light/gp2ap002.c
@@ -258,7 +258,7 @@ static int gp2ap002_read_raw(struct iio_dev *indio_dev,
 		case IIO_LIGHT:
 			ret = gp2ap002_get_lux(gp2ap002);
 			if (ret < 0)
-				return ret;
+				goto out;
 			*val = ret;
 			ret = IIO_VAL_INT;
 			goto out;
-- 
2.34.1


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

* Re: [PATCH] iio: light: gp2ap002: Fix runtime PM leak in gp2ap002_read_raw()
  2026-09-16 16:36 [PATCH] iio: light: gp2ap002: Fix runtime PM leak in gp2ap002_read_raw() Wentao Liang
@ 2026-09-16 17:34 ` Linus Walleij
  2026-09-17  0:37   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2026-09-16 17:34 UTC (permalink / raw)
  To: Wentao Liang
  Cc: andy, dlechner, jic23, linux-iio, linux-kernel, nuno.sa,
	xc-racer2, stable

On Wed, Sep 16, 2026 at 6:37 PM Wentao Liang <vulab@iscas.ac.cn> wrote:

> pm_runtime_get_sync() increments the usage counter even on failure,
> so every successful call must be paired with a put. A failure of
> gp2ap002_get_lux() returned early and skipped the paired
> pm_runtime_put_autosuspend(), permanently preventing runtime
> suspend. Jump to the common exit that releases the reference.
>
> Fixes: f6dbf83c17cb ("iio: light: gp2ap002: Take runtime PM reference on light read")
> Cc: stable@vger.kernel.org

IMO not stable material.

> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>

Reviewed-by: Linus Walleij <linusw@kernel.org>

Yours,
Linus Walleij

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

* Re: [PATCH] iio: light: gp2ap002: Fix runtime PM leak in gp2ap002_read_raw()
  2026-09-16 17:34 ` Linus Walleij
@ 2026-09-17  0:37   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2026-09-17  0:37 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Wentao Liang, andy, dlechner, linux-iio, linux-kernel, nuno.sa,
	xc-racer2, stable

On Wed, 16 Sep 2026 19:34:56 +0200
Linus Walleij <linusw@kernel.org> wrote:

> On Wed, Sep 16, 2026 at 6:37 PM Wentao Liang <vulab@iscas.ac.cn> wrote:
> 
> > pm_runtime_get_sync() increments the usage counter even on failure,
> > so every successful call must be paired with a put. A failure of
> > gp2ap002_get_lux() returned early and skipped the paired
> > pm_runtime_put_autosuspend(), permanently preventing runtime
> > suspend. Jump to the common exit that releases the reference.
> >
> > Fixes: f6dbf83c17cb ("iio: light: gp2ap002: Take runtime PM reference on light read")
> > Cc: stable@vger.kernel.org  
> 
> IMO not stable material.

Also that's not what upstream looks like:

https://elixir.bootlin.com/linux/v7.2.5/source/drivers/iio/light/gp2ap002.c#L246

Wentao, that function would definitely benefit form use of the
ACQUIRE macros in pm_runtime.h though if you do want to
improve it.

> 
> > Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>  
> 
> Reviewed-by: Linus Walleij <linusw@kernel.org>
> 
> Yours,
> Linus Walleij


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

end of thread, other threads:[~2026-09-17  0:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-16 16:36 [PATCH] iio: light: gp2ap002: Fix runtime PM leak in gp2ap002_read_raw() Wentao Liang
2026-09-16 17:34 ` Linus Walleij
2026-09-17  0:37   ` 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®