From a3f438368c596040efbc44aa8a65e4e5ef2f3847 Mon Sep 17 00:00:00 2001 From: Jiale Yao Date: Fri, 25 Sep 2026 21:17:30 +0800 Subject: [PATCH] iio: amplifiers: ad8366: reject devices without match data 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 Cc: stable@vger.kernel.org Signed-off-by: Jonathan Cameron --- 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))