* [PATCH 0/7] iio: validate SPI match data before use
@ 2026-09-25 13:17 Jiale Yao
2026-09-25 13:17 ` [PATCH 1/7] iio: amplifiers: ad8366: reject devices without match data Jiale Yao
` (7 more replies)
0 siblings, 8 replies; 10+ messages in thread
From: Jiale Yao @ 2026-09-25 13:17 UTC (permalink / raw)
To: Nuno Sá,
Michael Hennerich, Rodrigo Alencar, Jonathan Cameron,
David Lechner, Andy Shevchenko, Anshul Dalal, Antoniu Miclaus,
Herve Codina, Uwe Kleine-König (The Capable Hub),
Shi Hao, Linus Walleij, Krzysztof Kozlowski, Angel Iglesias,
linux, linux-iio, linux-kernel
Cc: Jiale Yao
SPI driver_override can bind a device without a matching entry in the
driver's ID tables. spi_get_device_match_data() then returns NULL.
These seven IIO drivers use that result without checking it, causing a
NULL pointer dereference during probe. Add the missing checks before
the match data is used.
Jiale Yao (7):
iio: amplifiers: ad8366: reject devices without match data
iio: dac: ad5755: validate SPI match data
iio: dac: mcp4821: reject devices without match data
iio: frequency: adf4377: reject devices without match data
iio: imu: adis16400: validate SPI match data
iio: potentiometer: x9250: reject devices without match data
iio: pressure: bmp280: validate SPI match data
drivers/iio/amplifiers/ad8366.c | 2 ++
drivers/iio/dac/ad5755.c | 3 +++
drivers/iio/dac/mcp4821.c | 7 +++++--
drivers/iio/frequency/adf4377.c | 3 +++
drivers/iio/imu/adis16400.c | 3 +++
drivers/iio/potentiometer/x9250.c | 7 ++++++-
drivers/iio/pressure/bmp280-spi.c | 2 ++
7 files changed, 24 insertions(+), 3 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/7] iio: amplifiers: ad8366: reject devices without match data
2026-09-25 13:17 [PATCH 0/7] iio: validate SPI match data before use Jiale Yao
@ 2026-09-25 13:17 ` Jiale Yao
2026-09-25 13:17 ` [PATCH 2/7] iio: dac: ad5755: validate SPI " Jiale Yao
` (6 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Jiale Yao @ 2026-09-25 13:17 UTC (permalink / raw)
To: Michael Hennerich, Rodrigo Alencar, Nuno Sá,
Jonathan Cameron, David Lechner, Andy Shevchenko, linux-iio,
linux, linux-kernel
Cc: Jiale Yao
A device bound through driver_override need not match an entry in the
driver tables. In that case spi_get_device_match_data() returns NULL,
but ad8366_probe() later dereferences the result while setting up the
IIO device.
Reject devices without match data before using the chip information.
Fixes: d5e02d0d00b9 ("iio: amplifiers: ad8366: add device tree support")
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
drivers/iio/amplifiers/ad8366.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
index e12f8604f59f..9adff120de1a 100644
--- a/drivers/iio/amplifiers/ad8366.c
+++ b/drivers/iio/amplifiers/ad8366.c
@@ -326,6 +326,8 @@ static int ad8366_probe(struct spi_device *spi)
st->spi = spi;
st->info = spi_get_device_match_data(spi);
+ if (!st->info)
+ return -ENODATA;
enable_gpio = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_HIGH);
if (IS_ERR(enable_gpio))
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/7] iio: dac: ad5755: validate SPI match data
2026-09-25 13:17 [PATCH 0/7] iio: validate SPI match data before use Jiale Yao
2026-09-25 13:17 ` [PATCH 1/7] iio: amplifiers: ad8366: reject devices without match data Jiale Yao
@ 2026-09-25 13:17 ` Jiale Yao
2026-09-25 13:17 ` [PATCH 3/7] iio: dac: mcp4821: reject devices without " Jiale Yao
` (5 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Jiale Yao @ 2026-09-25 13:17 UTC (permalink / raw)
To: Nuno Sá,
Michael Hennerich, Jonathan Cameron, David Lechner,
Andy Shevchenko, Krzysztof Kozlowski, linux, linux-iio,
linux-kernel
Cc: Jiale Yao
A device bound through driver_override need not match an entry in the
driver tables. In that case spi_get_device_match_data() returns NULL,
but ad5755_probe() stores and later dereferences the result.
Validate the match data before it is used.
Fixes: 62d3fb9dcc09 ("iio: dac: ad5755: make use of of_device_id table")
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
drivers/iio/dac/ad5755.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/iio/dac/ad5755.c b/drivers/iio/dac/ad5755.c
index 0828b9909099..730289dd8ef6 100644
--- a/drivers/iio/dac/ad5755.c
+++ b/drivers/iio/dac/ad5755.c
@@ -819,6 +819,9 @@ static int ad5755_probe(struct spi_device *spi)
spi_set_drvdata(spi, indio_dev);
st->chip_info = spi_get_device_match_data(spi);
+ if (!st->chip_info)
+ return -ENODATA;
+
st->spi = spi;
st->pwr_down = 0xf;
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 3/7] iio: dac: mcp4821: reject devices without match data
2026-09-25 13:17 [PATCH 0/7] iio: validate SPI match data before use Jiale Yao
2026-09-25 13:17 ` [PATCH 1/7] iio: amplifiers: ad8366: reject devices without match data Jiale Yao
2026-09-25 13:17 ` [PATCH 2/7] iio: dac: ad5755: validate SPI " Jiale Yao
@ 2026-09-25 13:17 ` Jiale Yao
2026-09-25 13:17 ` [PATCH 4/7] iio: frequency: adf4377: " Jiale Yao
` (4 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Jiale Yao @ 2026-09-25 13:17 UTC (permalink / raw)
To: Anshul Dalal, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel
Cc: Jiale Yao
A device bound through driver_override need not match an entry in the
driver tables. In that case spi_get_device_match_data() returns NULL,
but mcp4821_probe() dereferences the result while configuring the IIO
device.
Reject devices without match data before using the chip information.
Fixes: cdf3ecb0d8d0 ("iio: dac: driver for MCP4821")
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
drivers/iio/dac/mcp4821.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/dac/mcp4821.c b/drivers/iio/dac/mcp4821.c
index 8d8c00cd60e9..59defb1b5e62 100644
--- a/drivers/iio/dac/mcp4821.c
+++ b/drivers/iio/dac/mcp4821.c
@@ -255,9 +255,13 @@ static const struct iio_info mcp4821_info = {
static int mcp4821_probe(struct spi_device *spi)
{
+ const struct mcp4821_chip_info *info;
struct iio_dev *indio_dev;
struct mcp4821_state *state;
- const struct mcp4821_chip_info *info;
+
+ info = spi_get_device_match_data(spi);
+ if (!info)
+ return -ENODATA;
indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*state));
if (indio_dev == NULL)
@@ -268,7 +272,6 @@ static int mcp4821_probe(struct spi_device *spi)
/* default gain is 2x */
state->gain = 2;
- info = spi_get_device_match_data(spi);
indio_dev->name = info->name;
indio_dev->info = &mcp4821_info;
indio_dev->modes = INDIO_DIRECT_MODE;
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 4/7] iio: frequency: adf4377: reject devices without match data
2026-09-25 13:17 [PATCH 0/7] iio: validate SPI match data before use Jiale Yao
` (2 preceding siblings ...)
2026-09-25 13:17 ` [PATCH 3/7] iio: dac: mcp4821: reject devices without " Jiale Yao
@ 2026-09-25 13:17 ` Jiale Yao
2026-09-25 13:17 ` [PATCH 5/7] iio: imu: adis16400: validate SPI " Jiale Yao
` (3 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Jiale Yao @ 2026-09-25 13:17 UTC (permalink / raw)
To: Nuno Sá,
Michael Hennerich, Antoniu Miclaus, Jonathan Cameron,
David Lechner, Andy Shevchenko, linux, linux-iio, linux-kernel
Cc: Jiale Yao
A device bound through driver_override need not match an entry in the
driver tables. In that case spi_get_device_match_data() returns NULL,
but the result is later dereferenced by the property parsing and
initialization paths.
Reject devices without match data before continuing probe.
Fixes: 6140a92cd086 ("iio: frequency: adf4377: add adf4378 support")
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
drivers/iio/frequency/adf4377.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/iio/frequency/adf4377.c b/drivers/iio/frequency/adf4377.c
index 4dd19a9aa994..d1e5bb062474 100644
--- a/drivers/iio/frequency/adf4377.c
+++ b/drivers/iio/frequency/adf4377.c
@@ -1060,6 +1060,9 @@ static int adf4377_probe(struct spi_device *spi)
st->regmap = regmap;
st->spi = spi;
st->chip_info = spi_get_device_match_data(spi);
+ if (!st->chip_info)
+ return -ENODATA;
+
mutex_init(&st->lock);
ret = adf4377_properties_parse(st);
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 5/7] iio: imu: adis16400: validate SPI match data
2026-09-25 13:17 [PATCH 0/7] iio: validate SPI match data before use Jiale Yao
` (3 preceding siblings ...)
2026-09-25 13:17 ` [PATCH 4/7] iio: frequency: adf4377: " Jiale Yao
@ 2026-09-25 13:17 ` Jiale Yao
2026-09-25 13:17 ` [PATCH 6/7] iio: potentiometer: x9250: reject devices without " Jiale Yao
` (2 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Jiale Yao @ 2026-09-25 13:17 UTC (permalink / raw)
To: Nuno Sá,
Michael Hennerich, Jonathan Cameron, David Lechner,
Andy Shevchenko, linux, linux-iio, linux-kernel
Cc: Jiale Yao
A device bound through driver_override need not match an entry in the
driver tables. In that case spi_get_device_match_data() returns NULL,
but adis16400_probe() immediately dereferences the result.
Validate the match data before it is used.
Fixes: 2ef920e0e5c0 ("iio: imu: adis16400: Use separate structures rather than an array for chip info")
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
drivers/iio/imu/adis16400.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/iio/imu/adis16400.c b/drivers/iio/imu/adis16400.c
index 4842346f9f0c..28ad2d62d984 100644
--- a/drivers/iio/imu/adis16400.c
+++ b/drivers/iio/imu/adis16400.c
@@ -1150,6 +1150,9 @@ static int adis16400_probe(struct spi_device *spi)
/* setup the industrialio driver allocated elements */
st->variant = spi_get_device_match_data(spi);
+ if (!st->variant)
+ return -ENODATA;
+
indio_dev->name = spi_get_device_id(spi)->name;
indio_dev->channels = st->variant->channels;
indio_dev->num_channels = st->variant->num_channels;
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 6/7] iio: potentiometer: x9250: reject devices without match data
2026-09-25 13:17 [PATCH 0/7] iio: validate SPI match data before use Jiale Yao
` (4 preceding siblings ...)
2026-09-25 13:17 ` [PATCH 5/7] iio: imu: adis16400: validate SPI " Jiale Yao
@ 2026-09-25 13:17 ` Jiale Yao
2026-09-25 13:17 ` [PATCH 7/7] iio: pressure: bmp280: validate SPI " Jiale Yao
2026-09-26 1:11 ` [PATCH 0/7] iio: validate SPI match data before use Jonathan Cameron
7 siblings, 0 replies; 10+ messages in thread
From: Jiale Yao @ 2026-09-25 13:17 UTC (permalink / raw)
To: Herve Codina, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel
Cc: Jiale Yao
A device bound through driver_override need not match an entry in the
driver tables. In that case spi_get_device_match_data() returns NULL,
but x9250_probe() later dereferences the result while naming the IIO
device.
Reject devices without match data before enabling the regulators.
Fixes: 66bfc528a6fd ("iio: potentiometer: Add support for the Renesas X9250 potentiometers")
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
drivers/iio/potentiometer/x9250.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/potentiometer/x9250.c b/drivers/iio/potentiometer/x9250.c
index 974e4447fc2c..675b78677baa 100644
--- a/drivers/iio/potentiometer/x9250.c
+++ b/drivers/iio/potentiometer/x9250.c
@@ -155,10 +155,15 @@ static const char *const x9250_regulator_names[] = {
static int x9250_probe(struct spi_device *spi)
{
+ const struct x9250_cfg *cfg;
struct iio_dev *indio_dev;
struct x9250 *x9250;
int ret;
+ cfg = spi_get_device_match_data(spi);
+ if (!cfg)
+ return -ENODATA;
+
ret = devm_regulator_bulk_get_enable(&spi->dev, ARRAY_SIZE(x9250_regulator_names),
x9250_regulator_names);
if (ret)
@@ -176,7 +181,7 @@ static int x9250_probe(struct spi_device *spi)
x9250 = iio_priv(indio_dev);
x9250->spi = spi;
- x9250->cfg = spi_get_device_match_data(spi);
+ x9250->cfg = cfg;
x9250->wp_gpio = devm_gpiod_get_optional(&spi->dev, "wp", GPIOD_OUT_LOW);
if (IS_ERR(x9250->wp_gpio))
return dev_err_probe(&spi->dev, PTR_ERR(x9250->wp_gpio),
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 7/7] iio: pressure: bmp280: validate SPI match data
2026-09-25 13:17 [PATCH 0/7] iio: validate SPI match data before use Jiale Yao
` (5 preceding siblings ...)
2026-09-25 13:17 ` [PATCH 6/7] iio: potentiometer: x9250: reject devices without " Jiale Yao
@ 2026-09-25 13:17 ` Jiale Yao
2026-09-26 1:11 ` [PATCH 0/7] iio: validate SPI match data before use Jonathan Cameron
7 siblings, 0 replies; 10+ messages in thread
From: Jiale Yao @ 2026-09-25 13:17 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Uwe Kleine-König (The Capable Hub),
Shi Hao, Linus Walleij, Angel Iglesias, linux-iio, linux-kernel
Cc: Jiale Yao
A device bound through driver_override need not match an entry in the
driver tables. In that case spi_get_device_match_data() returns NULL,
but bmp280_spi_probe() immediately dereferences the result.
Validate the match data before selecting the regmap bus.
Fixes: faac4dda9a91 ("iio: pressure: bmp280: Use spi_get_device_match_data()")
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
drivers/iio/pressure/bmp280-spi.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/iio/pressure/bmp280-spi.c b/drivers/iio/pressure/bmp280-spi.c
index a02a621b8015..95d9635f4711 100644
--- a/drivers/iio/pressure/bmp280-spi.c
+++ b/drivers/iio/pressure/bmp280-spi.c
@@ -83,6 +83,8 @@ static int bmp280_spi_probe(struct spi_device *spi)
struct regmap *regmap;
chip_info = spi_get_device_match_data(spi);
+ if (!chip_info)
+ return -ENODATA;
if (chip_info->spi_read_extra_byte)
bmp_regmap_bus = &bmp380_regmap_bus;
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/7] iio: validate SPI match data before use
2026-09-25 13:17 [PATCH 0/7] iio: validate SPI match data before use Jiale Yao
` (6 preceding siblings ...)
2026-09-25 13:17 ` [PATCH 7/7] iio: pressure: bmp280: validate SPI " Jiale Yao
@ 2026-09-26 1:11 ` Jonathan Cameron
2026-09-26 6:13 ` Uwe Kleine-König (The Capable Hub)
7 siblings, 1 reply; 10+ messages in thread
From: Jonathan Cameron @ 2026-09-26 1:11 UTC (permalink / raw)
To: Jiale Yao
Cc: Nuno Sá,
Michael Hennerich, Rodrigo Alencar, David Lechner,
Andy Shevchenko, Anshul Dalal, Antoniu Miclaus, Herve Codina,
Uwe Kleine-König (The Capable Hub),
Shi Hao, Linus Walleij, Krzysztof Kozlowski, Angel Iglesias,
linux, linux-iio, linux-kernel
On Fri, 25 Sep 2026 21:17:29 +0800
Jiale Yao <yaojiale02@163.com> wrote:
> SPI driver_override can bind a device without a matching entry in the
> driver's ID tables. spi_get_device_match_data() then returns NULL.
>
> These seven IIO drivers use that result without checking it, causing a
> NULL pointer dereference during probe. Add the missing checks before
> the match data is used.
I was hoping we'd close this finally by adding a flag to the
drivers to say they should fail a match if driver_override is set.
Given I thought maybe that would happen when Andy looked into this
a while back I've been sitting on this problem for a while.
Unfortunately seems we have to carry on papering over it in the
drivers for now :(
Ah well. Series is fine, so applied and marked for stable.
I'm not going to rush these in though so they can wait for the
next merge window.
Thanks
Jonathan
>
> Jiale Yao (7):
> iio: amplifiers: ad8366: reject devices without match data
> iio: dac: ad5755: validate SPI match data
> iio: dac: mcp4821: reject devices without match data
> iio: frequency: adf4377: reject devices without match data
> iio: imu: adis16400: validate SPI match data
> iio: potentiometer: x9250: reject devices without match data
> iio: pressure: bmp280: validate SPI match data
>
> drivers/iio/amplifiers/ad8366.c | 2 ++
> drivers/iio/dac/ad5755.c | 3 +++
> drivers/iio/dac/mcp4821.c | 7 +++++--
> drivers/iio/frequency/adf4377.c | 3 +++
> drivers/iio/imu/adis16400.c | 3 +++
> drivers/iio/potentiometer/x9250.c | 7 ++++++-
> drivers/iio/pressure/bmp280-spi.c | 2 ++
> 7 files changed, 24 insertions(+), 3 deletions(-)
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/7] iio: validate SPI match data before use
2026-09-26 1:11 ` [PATCH 0/7] iio: validate SPI match data before use Jonathan Cameron
@ 2026-09-26 6:13 ` Uwe Kleine-König (The Capable Hub)
0 siblings, 0 replies; 10+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-09-26 6:13 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Jiale Yao, Nuno Sá,
Michael Hennerich, Rodrigo Alencar, David Lechner,
Andy Shevchenko, Anshul Dalal, Antoniu Miclaus, Herve Codina,
Shi Hao, Linus Walleij, Krzysztof Kozlowski, Angel Iglesias,
linux, linux-iio, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1018 bytes --]
Hello Jonathan,
On Sat, Sep 26, 2026 at 02:11:43AM +0100, Jonathan Cameron wrote:
> On Fri, 25 Sep 2026 21:17:29 +0800
> Jiale Yao <yaojiale02@163.com> wrote:
>
> > SPI driver_override can bind a device without a matching entry in the
> > driver's ID tables. spi_get_device_match_data() then returns NULL.
> >
> > These seven IIO drivers use that result without checking it, causing a
> > NULL pointer dereference during probe. Add the missing checks before
> > the match data is used.
>
> I was hoping we'd close this finally by adding a flag to the
> drivers to say they should fail a match if driver_override is set.
> Given I thought maybe that would happen when Andy looked into this
> a while back I've been sitting on this problem for a while.
>
>
> Unfortunately seems we have to carry on papering over it in the
> drivers for now :(
Note there is another effort:
https://lore.kernel.org/lkml/20260922-driver-override-opt-out-v1-0-58c35ded3b83@nvidia.com/
Best regards
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-09-26 6:13 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-25 13:17 [PATCH 0/7] iio: validate SPI match data before use Jiale Yao
2026-09-25 13:17 ` [PATCH 1/7] iio: amplifiers: ad8366: reject devices without match data Jiale Yao
2026-09-25 13:17 ` [PATCH 2/7] iio: dac: ad5755: validate SPI " Jiale Yao
2026-09-25 13:17 ` [PATCH 3/7] iio: dac: mcp4821: reject devices without " Jiale Yao
2026-09-25 13:17 ` [PATCH 4/7] iio: frequency: adf4377: " Jiale Yao
2026-09-25 13:17 ` [PATCH 5/7] iio: imu: adis16400: validate SPI " Jiale Yao
2026-09-25 13:17 ` [PATCH 6/7] iio: potentiometer: x9250: reject devices without " Jiale Yao
2026-09-25 13:17 ` [PATCH 7/7] iio: pressure: bmp280: validate SPI " Jiale Yao
2026-09-26 1:11 ` [PATCH 0/7] iio: validate SPI match data before use Jonathan Cameron
2026-09-26 6:13 ` Uwe Kleine-König (The Capable Hub)
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®