mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Guangshuo Li <lgs201920130244@gmail.com>
Cc: "Francesco Dolcini" <francesco@dolcini.it>,
	"João Paulo Gonçalves" <jpaulo.silvagoncalves@gmail.com>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: adc: ti-ads1119: fix PM reference leak in buffer preenable
Date: Wed, 3 Jun 2026 13:52:01 +0100	[thread overview]
Message-ID: <20260603135201.0e484c7b@jic23-huawei> (raw)
In-Reply-To: <20260603121640.1394763-1-lgs201920130244@gmail.com>

On Wed,  3 Jun 2026 20:16:40 +0800
Guangshuo Li <lgs201920130244@gmail.com> wrote:

> ads1119_triggered_buffer_preenable() resumes the device with
> pm_runtime_resume_and_get() before starting a conversion.
> 
> If i2c_smbus_write_byte() fails, the function returns the error directly
> and leaves the runtime PM usage counter elevated. The matching
> postdisable callback is not called when preenable fails, so the reference
> is leaked and the device may remain runtime-active indefinitely.
> 
> Store the I2C transfer result in ret and drop the runtime PM reference on
> failure before returning the error.
> 
> Fixes: a9306887eba41 ("iio: adc: ti-ads1119: Add driver")
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
Applied to the fixes-togreg branch of iio.git and marked for stable.

Note I may well drag these across to the togreg branch for the coming
merge window as I'm not really expecting to squeeze in another fixes
pull this cycle and all the fixes I currently have queued are for ancient
bugs.

> ---
>  drivers/iio/adc/ti-ads1119.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/ti-ads1119.c b/drivers/iio/adc/ti-ads1119.c
> index 79be71b4de96..9324408cb3b0 100644
> --- a/drivers/iio/adc/ti-ads1119.c
> +++ b/drivers/iio/adc/ti-ads1119.c
> @@ -459,7 +459,11 @@ static int ads1119_triggered_buffer_preenable(struct iio_dev *indio_dev)
>  	if (ret)
>  		return ret;
>  
> -	return i2c_smbus_write_byte(st->client, ADS1119_CMD_START_SYNC);
> +	ret = i2c_smbus_write_byte(st->client, ADS1119_CMD_START_SYNC);
> +	if (ret)
> +		pm_runtime_put_autosuspend(dev);
> +
> +	return ret;
>  }
>  
>  static int ads1119_triggered_buffer_postdisable(struct iio_dev *indio_dev)


      reply	other threads:[~2026-06-03 12:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-03 12:16 Guangshuo Li
2026-06-03 12:52 ` Jonathan Cameron [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260603135201.0e484c7b@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=francesco@dolcini.it \
    --cc=jpaulo.silvagoncalves@gmail.com \
    --cc=lgs201920130244@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®