Skip to contentSkip to conversation

iio: adc: ti-ads1119: Fix unbalanced pm reference count in ds1119_single_conversion()

PATCH In review Felix Gu 3 participants 3 messages Feb 27 – Feb 28

Subsystems (2)
lore
Share & tools
lore

Felix Gu

author
#0 lore raw

PATCH 1/1 iio: adc: ti-ads1119: Fix unbalanced pm reference count in ds1119_single_conversion()

In ads1119_single_conversion(), if pm_runtime_resume_and_get() fails, the code jumps to the pdown label, which calls pm_runtime_put_autosuspend().

Since pm_runtime_resume_and_get() automatically decrements the usage counter on failure, the subsequent call to pm_runtime_put_autosuspend() causes an unbalanced reference counter.

Fixes a9306887eba4 ("iio: adc: ti-ads1119: Add driver")
---
 drivers/iio/adc/ti-ads1119.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ti-ads1119.c +1 -1
index c9cedc59cdcd..4454f28b2b58 100644
@@ -274,7 +274,7 @@ static int ads1119_single_conversion(struct ads1119_state *st,
 
 	ret = pm_runtime_resume_and_get(dev);
 	if (ret)
-		goto pdown;
+		return ret;
 
 	ret = ads1119_configure_channel(st, mux, gain, datarate);
 	if (ret)

---
base-commit: 7d6661873f6b54c75195780a40d66bad3d482d8f
change-id: 20260228-ads1119-66b5271ef827

Best regards,

Signature · 1 line
Felix Gu <[email protected]>
maintainer
#1 lore raw
Quoted 10 lines · On Sat, 28 Feb 2026 01:48:19 +0800 Felix Gu <[email protected]> wrote:

In ads1119_single_conversion(), if pm_runtime_resume_and_get() fails, the code jumps to the pdown label, which calls pm_runtime_put_autosuspend().

Since pm_runtime_resume_and_get() automatically decrements the usage counter on failure, the subsequent call to pm_runtime_put_autosuspend() causes an unbalanced reference counter.

Fixes a9306887eba4 ("iio: adc: ti-ads1119: Add driver")

Hi Felix,

Looks correct to me. Applied to the fixes-togreg branch of iio.git and pushed out as testing.

More eyes always welcome though if others have time to take a look.

Jonathan

Quoted 23 lines
---
 drivers/iio/adc/ti-ads1119.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ti-ads1119.c +1 -2
index c9cedc59cdcd..4454f28b2b58 100644
@@ -274,7 +274,7 @@ static int ads1119_single_conversion(struct ads1119_state *st,
 
 	ret = pm_runtime_resume_and_get(dev);
 	if (ret)
-		goto pdown;
+		return ret;
 
 	ret = ads1119_configure_channel(st, mux, gain, datarate);
 	if (ret)
 
---

base-commit: 7d6661873f6b54c75195780a40d66bad3d482d8f
change-id: 20260228-ads1119-66b5271ef827

Best regards,

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Felix Gu

Hello,

Quoted 3 lines

Since pm_runtime_resume_and_get() automatically decrements the usage counter on failure, the subsequent call to pm_runtime_put_autosuspend() causes an unbalanced reference counter.

Thanks for the fix!

The change looks correct to me, considering the auto-cleanup implementation in pm_runtime. I need to take a proper look, but we probably can get rid of the pdown label by using PM_RUNTIME_ACQUIRE_IF_ENABLED_AUTOSUSPEND().

Att,
João Paulo