[PATCH] fpga: altera-ps-spi: reject devices without match data
From: Jiale Yao
Date: Fri Sep 25 2026 - 08:36:39 EST
SPI driver_override allows a device to bind to this driver without
matching either the OF or SPI device ID table. In that case,
spi_get_device_match_data() returns NULL.
The probe stores the result in conf->data and registers the FPGA
manager. A later programming request dereferences conf->data in
altera_ps_write_init() to obtain the device timing values, causing a
NULL pointer dereference.
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 before registering the manager.
Fixes: 3b08f52c2561 ("fpga: altera-ps-spi: Use spi_get_device_match_data()")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Jiale Yao <yaojiale02@xxxxxxx>
---
drivers/fpga/altera-ps-spi.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/fpga/altera-ps-spi.c b/drivers/fpga/altera-ps-spi.c
index d0ec3539b31f..69fcefce462c 100644
--- a/drivers/fpga/altera-ps-spi.c
+++ b/drivers/fpga/altera-ps-spi.c
@@ -240,6 +240,9 @@ static int altera_ps_probe(struct spi_device *spi)
return -ENOMEM;
conf->data = spi_get_device_match_data(spi);
+ if (!conf->data)
+ return -ENODATA;
+
conf->spi = spi;
conf->config = devm_gpiod_get(&spi->dev, "nconfig", GPIOD_OUT_LOW);
if (IS_ERR(conf->config)) {
--
2.34.1