Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: "Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Tomislav Denis" <tomislav.denis@avl.com>,
	"Matt Ranostay" <mranostay@gmail.com>,
	"Abhash Jha" <abhashkumarjha123@gmail.com>,
	"Petre Rodan" <petre.rodan@subdimension.ro>,
	"Mårten Lindahl" <martenli@axis.com>,
	"Dan Murphy" <dmurphy@ti.com>, "Sean Nyekjaer" <sean@geanix.com>,
	"Tomas Melin" <tomas.melin@vaisala.com>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>,
	"Lars-Peter Clausen" <lars@metafoo.de>,
	"Leonard Crestez" <cdleonard@gmail.com>,
	"Peter Meerwald-Stadler" <pmeerw@pmeerw.net>,
	"Neil Armstrong" <neil.armstrong@linaro.org>,
	"Dixit Parmar" <dixitparmar19@gmail.com>,
	"Matti Vaittinen" <mazziesaccount@gmail.com>,
	"Stepan Ionichev" <sozdayvek@gmail.com>,
	"Srinivas Pandruvada" <srinivas.pandruvada@linux.intel.com>,
	"Joachim Eastwood" <manabian@gmail.com>,
	"Tiberiu Breana" <tiberiu.a.breana@intel.com>,
	"Maxwell Doose" <maxwell@maxwelld.cc>,
	"Tomasz Duszynski" <tduszyns@gmail.com>,
	"Alison Schofield" <amsfield22@gmail.com>,
	"Christian Eggers" <ceggers@arri.de>,
	"Andreas Klinger" <ak@it-klinger.de>,
	linux-iio@vger.kernel.org, linux@analog.com
Cc: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH 02/25] iio: potentiostat: lmp91000: fix NULL deref setting immutable trigger
Date: Mon, 30 Nov 2026 00:01:10 +0000	[thread overview]
Message-ID: <20261130000110.00d93fc0@jic23-hlaptop> (raw)
In-Reply-To: <20261129-messing-fixes3323-v1-2-f01aa73aa628@oss.qualcomm.com>

On Sun, 29 Nov 2026 21:06:13 +0000
Jonathan Cameron <jic23@kernel.org> wrote:

> From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
> 
> lmp91000_probe() calls iio_channel_cb_get_iio_dev(data->cb_buffer) to
> find the ADC device on which to set the immutable trigger, but
> data->cb_buffer is only assigned later by iio_channel_get_all_cb(). At
> that point it is still NULL, so iio_channel_cb_get_iio_dev() dereferences
> a NULL pointer.
> 
> The call also took place before the trigger was registered, which
> triggers the WARN_ONCE() in iio_trigger_get() for an unregistered
> trigger.
> 
> Move the call to after the callback buffer has been obtained, when the
> trigger is also registered, and unwind the callback buffer on failure.
> 
> Fixes: 67e17300dc1d ("iio: potentiostat: add LMP91000 support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
> 
FWIW the sashiko comment on this one about leaking the immutable trigger
reference is entirely correct. It is addressed in the series that follows
which focuses on immutable triggers in general.  For now, just leak it.

> ---
> 
> LLM found this one whilst I was working on a broader cleanup.
> Note despite this being a nasty bug I'll most likely take it for
> the next merge window as I have a large series coming on top
> of this.
> ---
>  drivers/iio/potentiostat/lmp91000.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/potentiostat/lmp91000.c b/drivers/iio/potentiostat/lmp91000.c
> index 53f181cbc0b8..676e5e962a93 100644
> --- a/drivers/iio/potentiostat/lmp91000.c
> +++ b/drivers/iio/potentiostat/lmp91000.c
> @@ -330,13 +330,6 @@ static int lmp91000_probe(struct i2c_client *client)
>  	if (ret)
>  		return ret;
>  
> -	ret = iio_trigger_set_immutable(iio_channel_cb_get_iio_dev(data->cb_buffer),
> -					data->trig);
> -	if (ret) {
> -		dev_err(dev, "cannot set immutable trigger.\n");
> -		return ret;
> -	}
> -
>  	ret = iio_trigger_register(data->trig);
>  	if (ret) {
>  		dev_err(dev, "cannot register iio trigger.\n");
> @@ -363,6 +356,13 @@ static int lmp91000_probe(struct i2c_client *client)
>  
>  	data->adc_chan = iio_channel_cb_get_channels(data->cb_buffer);
>  
> +	ret = iio_trigger_set_immutable(iio_channel_cb_get_iio_dev(data->cb_buffer),
> +					data->trig);
> +	if (ret) {
> +		dev_err(dev, "cannot set immutable trigger.\n");
> +		goto error_unreg_cb_buffer;
> +	}
> +
>  	ret = iio_device_register(indio_dev);
>  	if (ret)
>  		goto error_unreg_cb_buffer;
> 


  reply	other threads:[~2026-11-30  0:01 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29 21:06 [PATCH 00/25] IIO: Various fixes mostly related to buffered capture Jonathan Cameron
2026-11-29 21:06 ` [PATCH 01/25] iio: adc: ti-ads131e08: fix the size of the scan buffer Jonathan Cameron
2026-11-29 21:06 ` [PATCH 02/25] iio: potentiostat: lmp91000: fix NULL deref setting immutable trigger Jonathan Cameron
2026-11-30  0:01   ` Jonathan Cameron [this message]
2026-11-29 21:06 ` [PATCH 03/25] iio: light: vl6180: notify trigger when reading data fails Jonathan Cameron
2026-11-29 21:06 ` [PATCH 04/25] iio: accel: bma220: return error if triggered buffer setup fails Jonathan Cameron
2026-11-29 21:06 ` [PATCH 05/25] iio: adc: ti-adc084s021: don't push stale data if the conversion fails Jonathan Cameron
2026-11-29 21:06 ` [PATCH 06/25] iio: adc: ti-ads124s08: don't push data if reading a channel fails Jonathan Cameron
2026-11-29 21:06 ` [PATCH 07/25] iio: adc: ti-ads8688: don't push an error code as a sample Jonathan Cameron
2026-11-29 21:06 ` [PATCH 08/25] iio: adc: ti-ads8688: take the lock in the trigger handler Jonathan Cameron
2026-11-29 21:06 ` [PATCH 09/25] iio: adc: ti-ads8688: fix the endianness in the channel description Jonathan Cameron
2026-11-29 21:06 ` [PATCH 10/25] iio: accel: sca3300: hold the lock across error handling in register access Jonathan Cameron
2026-11-29 21:06 ` [PATCH 11/25] iio: imu: adis16400: don't push stale data if the SPI transfer fails Jonathan Cameron
2026-11-29 21:06 ` [PATCH 12/25] iio: light: si1145: return IRQ_NONE if no interrupt is flagged Jonathan Cameron
2026-11-29 21:06 ` [PATCH 13/25] iio: magnetometer: als31300: print the regmap error code on read failure Jonathan Cameron
2026-11-30  8:38   ` Neil Armstrong
2026-11-29 21:06 ` [PATCH 14/25] iio: magnetometer: tlv493d: fix polling for valid data Jonathan Cameron
2026-11-29 21:06 ` [PATCH 15/25] iio: proximity: isl29501: don't push uninitialized data on read failure Jonathan Cameron
2026-11-29 21:06 ` [PATCH 16/25] iio: pressure: rohm-bm1390: only return IRQ_NONE if data ready is not set Jonathan Cameron
2026-11-30 11:03   ` Matti Vaittinen
2026-11-30 23:45     ` Jonathan Cameron
2026-12-02 16:01       ` Matti Vaittinen
2026-11-29 21:06 ` [PATCH 17/25] iio: accel: kxcjk-1013: claim direct mode for raw reads Jonathan Cameron
2026-11-29 21:06 ` [PATCH 18/25] iio: accel: mma7455: " Jonathan Cameron
2026-11-29 21:06 ` [PATCH 19/25] iio: accel: mxc4005: " Jonathan Cameron
2026-11-29 21:06 ` [PATCH 20/25] iio: accel: stk8ba50: " Jonathan Cameron
2026-11-29 21:06 ` [PATCH 21/25] iio: chemical: scd30: claim direct mode before taking the lock in read_raw() Jonathan Cameron
2026-11-29 21:06 ` [PATCH 22/25] iio: humidity: hdc100x: " Jonathan Cameron
2026-11-29 21:06 ` [PATCH 23/25] iio: light: as73211: claim direct mode before taking the lock in write_raw() Jonathan Cameron
2026-11-29 21:06 ` [PATCH 24/25] iio: light: veml6046x00: claim direct mode before starting a single read Jonathan Cameron
2026-11-29 21:06 ` [PATCH 25/25] iio: magnetometer: bmc150_magn: claim direct mode for raw reads Jonathan Cameron
2026-11-30  0:20 ` [PATCH 00/25] IIO: Various fixes mostly related to buffered capture Jonathan Cameron

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=20261130000110.00d93fc0@jic23-hlaptop \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=abhashkumarjha123@gmail.com \
    --cc=ak@it-klinger.de \
    --cc=amsfield22@gmail.com \
    --cc=andy@kernel.org \
    --cc=cdleonard@gmail.com \
    --cc=ceggers@arri.de \
    --cc=dixitparmar19@gmail.com \
    --cc=dlechner@baylibre.com \
    --cc=dmurphy@ti.com \
    --cc=jonathan.cameron@oss.qualcomm.com \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux@analog.com \
    --cc=manabian@gmail.com \
    --cc=martenli@axis.com \
    --cc=maxwell@maxwelld.cc \
    --cc=mazziesaccount@gmail.com \
    --cc=mranostay@gmail.com \
    --cc=neil.armstrong@linaro.org \
    --cc=nuno.sa@analog.com \
    --cc=petre.rodan@subdimension.ro \
    --cc=pmeerw@pmeerw.net \
    --cc=sean@geanix.com \
    --cc=sozdayvek@gmail.com \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=stable@vger.kernel.org \
    --cc=tduszyns@gmail.com \
    --cc=tiberiu.a.breana@intel.com \
    --cc=tomas.melin@vaisala.com \
    --cc=tomislav.denis@avl.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