mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iio: chemical: atlas-sensor: fix PM reference leak in buffer postenable
@ 2026-07-13  3:00 Moksh Panicker
  2026-07-22  2:04 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Moksh Panicker @ 2026-07-13  3:00 UTC (permalink / raw)
  To: jic23; +Cc: dlechner, linux-iio, linux-kernel, stable, skhan, Moksh Panicker

atlas_buffer_postenable() acquires a runtime PM reference with
pm_runtime_resume_and_get() but returns the result of
atlas_set_interrupt() directly. If atlas_set_interrupt() fails,
the runtime PM reference is leaked and the device can never
autosuspend.

Add pm_runtime_put_autosuspend() on the error path to balance
the reference.

Fixes: 0e4f336f50de ("iio: chemical: atlas-sensor: Balance runtime pm + pm_runtime_resume_and_get()")
Cc: stable@vger.kernel.org
Signed-off-by: Moksh Panicker <mokshpanicker.7@gmail.com>
---
 drivers/iio/chemical/atlas-sensor.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/chemical/atlas-sensor.c b/drivers/iio/chemical/atlas-sensor.c
index 0e2edcff63f9..b2c1a598b3a5 100644
--- a/drivers/iio/chemical/atlas-sensor.c
+++ b/drivers/iio/chemical/atlas-sensor.c
@@ -413,7 +413,11 @@ static int atlas_buffer_postenable(struct iio_dev *indio_dev)
 	if (ret)
 		return ret;
 
-	return atlas_set_interrupt(data, true);
+	ret = atlas_set_interrupt(data, true);
+	if (ret)
+		pm_runtime_put_autosuspend(&data->client->dev);
+
+	return ret;
 }
 
 static int atlas_buffer_predisable(struct iio_dev *indio_dev)
-- 
2.34.1


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

* Re: [PATCH] iio: chemical: atlas-sensor: fix PM reference leak in buffer postenable
  2026-07-13  3:00 [PATCH] iio: chemical: atlas-sensor: fix PM reference leak in buffer postenable Moksh Panicker
@ 2026-07-22  2:04 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2026-07-22  2:04 UTC (permalink / raw)
  To: Moksh Panicker; +Cc: dlechner, linux-iio, linux-kernel, stable, skhan

On Mon, 13 Jul 2026 03:00:46 +0000
Moksh Panicker <mokshpanicker.7@gmail.com> wrote:

> atlas_buffer_postenable() acquires a runtime PM reference with
> pm_runtime_resume_and_get() but returns the result of
> atlas_set_interrupt() directly. If atlas_set_interrupt() fails,
> the runtime PM reference is leaked and the device can never
> autosuspend.
> 
> Add pm_runtime_put_autosuspend() on the error path to balance
> the reference.
> 
> Fixes: 0e4f336f50de ("iio: chemical: atlas-sensor: Balance runtime pm + pm_runtime_resume_and_get()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Moksh Panicker <mokshpanicker.7@gmail.com>
Hi,

I've applied this to the fixes-togreg branch of iio.git but Linus has been
pushing back on less critical fixes late in cycle so I might shuffle things
around to queue this for the next merge window instead.

Thanks

Jonathan

> ---
>  drivers/iio/chemical/atlas-sensor.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/chemical/atlas-sensor.c b/drivers/iio/chemical/atlas-sensor.c
> index 0e2edcff63f9..b2c1a598b3a5 100644
> --- a/drivers/iio/chemical/atlas-sensor.c
> +++ b/drivers/iio/chemical/atlas-sensor.c
> @@ -413,7 +413,11 @@ static int atlas_buffer_postenable(struct iio_dev *indio_dev)
>  	if (ret)
>  		return ret;
>  
> -	return atlas_set_interrupt(data, true);
> +	ret = atlas_set_interrupt(data, true);
> +	if (ret)
> +		pm_runtime_put_autosuspend(&data->client->dev);
> +
> +	return ret;
>  }
>  
>  static int atlas_buffer_predisable(struct iio_dev *indio_dev)


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

end of thread, other threads:[~2026-07-22  2:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-13  3:00 [PATCH] iio: chemical: atlas-sensor: fix PM reference leak in buffer postenable Moksh Panicker
2026-07-22  2:04 ` 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®