diff options
| author | Rodrigo Alencar <rodrigo.alencar@analog.com> | 2026-07-16 13:14:18 +0100 |
|---|---|---|
| committer | Jonathan Cameron <jonathan.cameron@oss.qualcomm.com> | 2026-07-19 23:16:13 +0100 |
| commit | 572a008526359cdac2fa935dad75e9d50a79792f (patch) | |
| tree | d0a91bc5438c5dba4731a4f8d94eab68250489a9 | |
| parent | a1c5ca7b8034efe2870a0e31aa1200530ead513f (diff) | |
| download | linux-572a008526359cdac2fa935dad75e9d50a79792f.tar.gz linux-572a008526359cdac2fa935dad75e9d50a79792f.zip | |
iio: dac: ad5686: missing NULL check on match data
Verify that chip_info pointer is not NULL. If a user binds the driver
using driver_override via sysfs with a device name not present in the
id_table or of_match_table, match data will be NULL.
Fixes: 0eb1728461a1 ("iio: dac: ad5686: drop enum id")
Reported-by: sashiko-bot@kernel.org
Closes: https://lore.kernel.org/all/20260710113149.53EC51F000E9@smtp.kernel.org/
Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
| -rw-r--r-- | drivers/iio/dac/ad5686-spi.c | 9 | ||||
| -rw-r--r-- | drivers/iio/dac/ad5696-i2c.c | 9 |
2 files changed, 14 insertions, 4 deletions
diff --git a/drivers/iio/dac/ad5686-spi.c b/drivers/iio/dac/ad5686-spi.c index 8abfaf8f0c46..859874ab861c 100644 --- a/drivers/iio/dac/ad5686-spi.c +++ b/drivers/iio/dac/ad5686-spi.c @@ -98,8 +98,13 @@ static const struct ad5686_bus_ops ad5686_spi_ops = { static int ad5686_spi_probe(struct spi_device *spi) { - return ad5686_probe(&spi->dev, spi_get_device_match_data(spi), - spi->modalias, &ad5686_spi_ops); + const struct ad5686_chip_info *info; + + info = spi_get_device_match_data(spi); + if (!info) + return -ENODATA; + + return ad5686_probe(&spi->dev, info, spi->modalias, &ad5686_spi_ops); } static const struct spi_device_id ad5686_spi_id[] = { diff --git a/drivers/iio/dac/ad5696-i2c.c b/drivers/iio/dac/ad5696-i2c.c index d49946adbde3..d5934405d555 100644 --- a/drivers/iio/dac/ad5696-i2c.c +++ b/drivers/iio/dac/ad5696-i2c.c @@ -68,8 +68,13 @@ static const struct ad5686_bus_ops ad5686_i2c_ops = { static int ad5686_i2c_probe(struct i2c_client *i2c) { - return ad5686_probe(&i2c->dev, i2c_get_match_data(i2c), - i2c->name, &ad5686_i2c_ops); + const struct ad5686_chip_info *info; + + info = i2c_get_match_data(i2c); + if (!info) + return -ENODATA; + + return ad5686_probe(&i2c->dev, info, i2c->name, &ad5686_i2c_ops); } static const struct i2c_device_id ad5686_i2c_id[] = { |
