iio: adc: ti-ads131e08: Fix trigger reference leak in ads131e08_probe()
Subsystems (2)
PATCH 1/1 iio: adc: ti-ads131e08: Fix trigger reference leak in ads131e08_probe()
The reference taken with iio_trigger_get() is only dropped by iio_dev_release() when INDIO_BUFFER_TRIGGERED is set. If devm_iio_triggered_buffer_setup() fails before setting that mode, the reference acquired for indio_dev->trig leaks. Move the iio_trigger_get() after the buffer setup succeeds.
--- drivers/iio/adc/ti-ads131e08.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/adc/ti-ads131e08.c +2 -2
@@ -851,8 +851,6 @@ static int ads131e08_probe(struct spi_device *spi)return ret; } - indio_dev->trig =iio_trigger_get (st->trig); - ret =devm_iio_triggered_buffer_setup (&spi->dev, indio_dev,NULL , &ads131e08_trigger_handler,NULL );if (ret) {
@@ -860,6 +858,8 @@ static int ads131e08_probe(struct spi_device *spi)return ret; } + indio_dev->trig =iio_trigger_get (st->trig); + st->vref_reg =devm_regulator_get_optional (&spi->dev,"vref" );if (!IS_ERR (st->vref_reg)) { ret =regulator_enable (st->vref_reg);
Signature · 1 line
2.34.1
Jonathan Cameron
maintainerQuoted 9 lines · On Wed, 16 Sep 2026 16:21:14 +0000 Wentao Liang <[email protected]> wrote:
The reference taken with
iio_trigger_get()is only dropped byiio_dev_release()whenINDIO_BUFFER_TRIGGEREDis set. Ifdevm_iio_triggered_buffer_setup()fails before setting that mode, the reference acquired forindio_dev->trigleaks. Move theiio_trigger_get()after the buffer setup succeeds.Fixes d935eddd2799 ("iio: adc: Add driver for Texas Instruments ADS131E0x ADC family")Signed-off-by Wentao Liang <[email protected]>
Not this solution. See other threads on this.
Quoted 26 lines
--- drivers/iio/adc/ti-ads131e08.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/iio/adc/ti-ads131e08.c +2
-2@@ -851,8 +851,6 @@ static int ads131e08_probe(struct spi_device *spi)return ret; } - indio_dev->trig =iio_trigger_get (st->trig); - ret =devm_iio_triggered_buffer_setup (&spi->dev, indio_dev,NULL , &ads131e08_trigger_handler,NULL );if (ret) {@@ -860,6 +858,8 @@ static int ads131e08_probe(struct spi_device *spi)return ret; } + indio_dev->trig =iio_trigger_get (st->trig); + st->vref_reg =devm_regulator_get_optional (&spi->dev,"vref" );if (!IS_ERR (st->vref_reg)) { ret =regulator_enable (st->vref_reg);
Hi Jonathan,
Sorry for the very late reply.
I understand your feedback: this fix should not depend on a subtle ordering constraint in the driver. Trigger lifetime handling needs a broader solution in the IIO core, as you explained in the bma220 thread.
Please disregard this patch; I will not resend this approach as v2. Thank you for the review.
For transparency, we use static analysis tools to identify candidates, then DeepSeek and GPT-6.1 Sol to assist with auditing and preparing fixes. I am responsible for verifying the findings and changes before submission.
Best regards,
Wentao