public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: adc: ti-ads1119: Fix unbalanced pm reference count in ds1119_single_conversion()
@ 2026-02-27 17:48 Felix Gu
  2026-02-28 11:25 ` Jonathan Cameron
  2026-02-28 19:22 ` João Paulo Gonçalves
  0 siblings, 2 replies; 3+ messages in thread
From: Felix Gu @ 2026-02-27 17:48 UTC (permalink / raw)
  To: Francesco Dolcini, João Paulo Gonçalves,
	Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko
  Cc: Francesco Dolcini, João Paulo Gonçalves,
	Jonathan Cameron, linux-iio, linux-kernel, Felix Gu

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")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
 drivers/iio/adc/ti-ads1119.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ti-ads1119.c b/drivers/iio/adc/ti-ads1119.c
index c9cedc59cdcd..4454f28b2b58 100644
--- a/drivers/iio/adc/ti-ads1119.c
+++ b/drivers/iio/adc/ti-ads1119.c
@@ -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,
-- 
Felix Gu <ustc.gu@gmail.com>


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

* Re: [PATCH] iio: adc: ti-ads1119: Fix unbalanced pm reference count in ds1119_single_conversion()
  2026-02-27 17:48 [PATCH] iio: adc: ti-ads1119: Fix unbalanced pm reference count in ds1119_single_conversion() Felix Gu
@ 2026-02-28 11:25 ` Jonathan Cameron
  2026-02-28 19:22 ` João Paulo Gonçalves
  1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2026-02-28 11:25 UTC (permalink / raw)
  To: Felix Gu
  Cc: Francesco Dolcini, João Paulo Gonçalves, David Lechner,
	Nuno Sá, Andy Shevchenko, Francesco Dolcini,
	João Paulo Gonçalves, Jonathan Cameron, linux-iio,
	linux-kernel

On Sat, 28 Feb 2026 01:48:19 +0800
Felix Gu <ustc.gu@gmail.com> 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")
> Signed-off-by: Felix Gu <ustc.gu@gmail.com>
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

> ---
>  drivers/iio/adc/ti-ads1119.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/ti-ads1119.c b/drivers/iio/adc/ti-ads1119.c
> index c9cedc59cdcd..4454f28b2b58 100644
> --- a/drivers/iio/adc/ti-ads1119.c
> +++ b/drivers/iio/adc/ti-ads1119.c
> @@ -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,


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

* Re: [PATCH] iio: adc: ti-ads1119: Fix unbalanced pm reference count in ds1119_single_conversion()
  2026-02-27 17:48 [PATCH] iio: adc: ti-ads1119: Fix unbalanced pm reference count in ds1119_single_conversion() Felix Gu
  2026-02-28 11:25 ` Jonathan Cameron
@ 2026-02-28 19:22 ` João Paulo Gonçalves
  1 sibling, 0 replies; 3+ messages in thread
From: João Paulo Gonçalves @ 2026-02-28 19:22 UTC (permalink / raw)
  To: Felix Gu
  Cc: Francesco Dolcini, Jonathan Cameron, David Lechner, Nuno Sá,
	Andy Shevchenko, Francesco Dolcini,
	João Paulo Gonçalves, Jonathan Cameron, linux-iio,
	linux-kernel

Hello,

> 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.

Reviewed-by: João Paulo Gonçalves <jpaulo.silvagoncalves@gmail.com>

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

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

end of thread, other threads:[~2026-02-28 19:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-27 17:48 [PATCH] iio: adc: ti-ads1119: Fix unbalanced pm reference count in ds1119_single_conversion() Felix Gu
2026-02-28 11:25 ` Jonathan Cameron
2026-02-28 19:22 ` João Paulo Gonçalves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox