[PATCH 7/7] iio: pressure: bmp280: validate SPI match data

From: Jiale Yao

Date: Fri Sep 25 2026 - 09:24:58 EST


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@xxxxxxx>
---
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