Skip to contentSkip to conversation

iio: chemical: atlas-sensor: fix PM reference leak in buffer postenable

PATCH In review Moksh Panicker 2 participants 2 messages Jul 13 – Jul 22

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: chemical: atlas-sensor: fix PM reference leak in buffer postenable

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()")
---
 drivers/iio/chemical/atlas-sensor.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/iio/chemical/atlas-sensor.c +5 -1
index 0e2edcff63f9..b2c1a598b3a5 100644
@@ -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)
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 6 lines · On Mon, 13 Jul 2026 03:00:46 +0000 Moksh Panicker <[email protected]>…

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.

Quoted 6 lines

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()")

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

Quoted 21 lines
---
 drivers/iio/chemical/atlas-sensor.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/iio/chemical/atlas-sensor.c +5 -1
index 0e2edcff63f9..b2c1a598b3a5 100644
@@ -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)