]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: adc: ti-ads1119: fix PM reference leak in buffer preenable
authorGuangshuo Li <lgs201920130244@gmail.com>
Wed, 3 Jun 2026 12:16:40 +0000 (20:16 +0800)
committerJonathan Cameron <jic23@kernel.org>
Mon, 29 Jun 2026 22:24:45 +0000 (23:24 +0100)
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>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/adc/ti-ads1119.c

index d31f3d6eb7811daca2f0f9cf460884164cfea8a7..b0f04741ddc6e7fa4bdfd02d3f8e833b2a3d73e9 100644 (file)
@@ -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)