mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
iio: accel: adxl313: 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. adxl313_spi_probe() dereferences chip_data to select the regmap configuration, 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 selecting the configuration. Fixes:d6e3ee74d1("iio: accel: adxl313: simplify with spi_get_device_match_data()") 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
6bdeaf23ef
commit
defd4c0b29
|
|
@ -79,6 +79,8 @@ static int adxl313_spi_probe(struct spi_device *spi)
|
|||
return ret;
|
||||
|
||||
chip_data = spi_get_device_match_data(spi);
|
||||
if (!chip_data)
|
||||
return -ENODATA;
|
||||
|
||||
regmap = devm_regmap_init_spi(spi,
|
||||
&adxl31x_spi_regmap_config[chip_data->type]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user