mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
iio: adc: ad7768-1: reject devices without match data
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. ad7768_probe() later dereferences the returned chip information to initialize the IIO channels and device name, causing a NULL pointer dereference. Commit572a008526("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 continuing the probe. Fixes:fa087f5bab("iio: adc: ad7768-1: introduce chip info for future multidevice support") Cc: stable@vger.kernel.org Signed-off-by: Jiale Yao <yaojiale02@163.com> Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
This commit is contained in:
parent
7830650d52
commit
e29630bd46
|
|
@ -1829,6 +1829,9 @@ static int ad7768_probe(struct spi_device *spi)
|
|||
}
|
||||
|
||||
st->chip = spi_get_device_match_data(spi);
|
||||
if (!st->chip)
|
||||
return -ENODATA;
|
||||
|
||||
st->spi = spi;
|
||||
|
||||
st->regmap = devm_regmap_init_spi(spi, &ad7768_regmap_config);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user