iio: adc: ti-ads1119: fix PM reference leak in buffer preenable
Subsystems (2)
PATCH 1/1 iio: adc: ti-ads1119: fix PM reference leak in buffer preenable
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.
--- drivers/iio/adc/ti-ads1119.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/iio/adc/ti-ads1119.c +5 -1
@@ -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)
Signature · 1 line
2.43.0
Quoted 8 lines · On Wed, 3 Jun 2026 20:16:40 +0800 Guangshuo Li <[email protected]>…
ads1119_triggered_buffer_preenable()resumes the device withpm_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.
Quoted 5 lines
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 <[email protected]>
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.
Quoted 21 lines
--- drivers/iio/adc/ti-ads1119.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/iio/adc/ti-ads1119.c +5
-1@@ -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)