From: Jonathan Cameron <jic23@kernel.org>
To: Jiale Yao <yaojiale02@163.com>
Cc: "Matti Vaittinen" <mazziesaccount@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,
stable@vger.kernel.org
Subject: Re: [PATCH 6/9] iio: adc: ti-adc128s052: validate SPI match data
Date: Sun, 27 Sep 2026 18:45:21 +0100 [thread overview]
Message-ID: <20260927184521.022ccf49@jic23-hlaptop> (raw)
In-Reply-To: <20260926021823.6493dbe2@jic23-hlaptop>
On Sat, 26 Sep 2026 02:18:23 +0100
Jonathan Cameron <jic23@kernel.org> wrote:
> On Sat, 26 Sep 2026 02:15:06 +0100
> Jonathan Cameron <jic23@kernel.org> wrote:
>
> > On Fri, 25 Sep 2026 20:57:44 +0800
> > Jiale Yao <yaojiale02@163.com> wrote:
> >
> > > SPI driver_override allows a device to bind to this driver without
> > > matching either the firmware tables or SPI device ID table. In that
> > > case, spi_get_device_match_data() returns NULL.
> > >
> > > adc128_probe() also obtains the IIO device name by dereferencing the
> > > result of spi_get_device_id(), which is NULL on the same override path.
> > > The probe can therefore crash before it reaches the match data access.
> > >
> > > Commit 572a00852635 ("iio: dac: ad5686: missing NULL check on match
> > > data") fixed the same driver_override issue in another SPI driver.
> > > Reject devices without match data and use the always available SPI
> > > modalias for the IIO device name.
> >
> > Why this change? The name is clearly encoded in a place that makes
> > it readily available and verifiably the right thing in a way that
> > spi->modalias does not.
> > There isn't any reason the IIO name would always match that even it
> > happens to do so here.
>
> Actually - ignore that, I misread this and assumed the code
> was different from what was actually there.
>
> Drivers shouldn't be using spi_get_device_id(spi)->name but
> I'm not sure modalias is any better.
>
> I'm out of time for now, so will revisit this in a day or so.
>
I did a bit of LLM assisted digging and it does seem that some
of the previous issues around these names and ACPI PRP0001 have
been resolved these days so as far as I can tell this ends
up the with the correct answer.
> >
> >
> > >
> > > Fixes: d5f0da0c6972 ("iio: adc: ti-adc128s052: Switch to use spi_get_device_match_data()")
> > > Cc: stable@vger.kernel.org
> > > Signed-off-by: Jiale Yao <yaojiale02@163.com>
> > > ---
> > > drivers/iio/adc/ti-adc128s052.c | 8 +++++---
> > > 1 file changed, 5 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c
> > > index 1899813c1aee..f9a995ff403e 100644
> > > --- a/drivers/iio/adc/ti-adc128s052.c
> > > +++ b/drivers/iio/adc/ti-adc128s052.c
> > > @@ -195,12 +195,14 @@ static int adc128_probe(struct spi_device *spi)
> > > adc = iio_priv(indio_dev);
> > > adc->spi = spi;
> > >
> > > - indio_dev->name = spi_get_device_id(spi)->name;
> > > + config = spi_get_device_match_data(spi);
> > > + if (!config)
> > > + return -ENODATA;
> > > +
> > > + indio_dev->name = spi->modalias;
> > > indio_dev->modes = INDIO_DIRECT_MODE;
> > > indio_dev->info = &adc128_info;
> > >
> > > - config = spi_get_device_match_data(spi);
> > > -
> > > indio_dev->channels = config->channels;
> > > indio_dev->num_channels = config->num_channels;
> > >
> >
> >
>
>
next prev parent reply other threads:[~2026-09-27 17:45 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-25 12:57 [PATCH 0/9] iio: adc: reject SPI devices without " Jiale Yao
2026-09-25 12:57 ` [PATCH 1/9] iio: adc: ad7192: reject " Jiale Yao
2026-09-25 12:57 ` [PATCH 2/9] iio: adc: ad7606: " Jiale Yao
2026-09-25 12:57 ` [PATCH 3/9] iio: adc: ad7768-1: " Jiale Yao
2026-09-25 12:57 ` [PATCH 4/9] iio: adc: max11205: " Jiale Yao
2026-09-25 12:57 ` [PATCH 5/9] iio: adc: mcp3911: " Jiale Yao
2026-09-25 12:57 ` [PATCH 6/9] iio: adc: ti-adc128s052: validate SPI " Jiale Yao
2026-09-26 1:15 ` Jonathan Cameron
2026-09-26 1:18 ` Jonathan Cameron
2026-09-27 17:45 ` Jonathan Cameron [this message]
2026-09-25 12:57 ` [PATCH 7/9] iio: adc: ti-ads1018: reject devices without " Jiale Yao
2026-09-25 19:24 ` Kurt Borja
2026-09-25 12:57 ` [PATCH 8/9] iio: adc: ti-ads131m02: " Jiale Yao
2026-09-25 12:57 ` [PATCH 9/9] iio: adc: ti-ads7950: validate SPI " Jiale Yao
2026-09-27 17:49 ` [PATCH 0/9] iio: adc: reject SPI devices without " 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=20260927184521.022ccf49@jic23-hlaptop \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mazziesaccount@gmail.com \
--cc=nuno.sa@analog.com \
--cc=stable@vger.kernel.org \
--cc=yaojiale02@163.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®