mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
iio: imu: adis16400: validate SPI 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 adis16400_probe() immediately dereferences the result.
Validate the match data before it is used.
Fixes: 2ef920e0e5 ("iio: imu: adis16400: Use separate structures rather than an array for chip info")
Signed-off-by: Jiale Yao <yaojiale02@163.com>
Cc: stable@vger.kernel.org
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
This commit is contained in:
parent
2f3196d27e
commit
2c01a0a1c5
|
|
@ -1153,6 +1153,9 @@ static int adis16400_probe(struct spi_device *spi)
|
|||
|
||||
/* setup the industrialio driver allocated elements */
|
||||
st->variant = spi_get_device_match_data(spi);
|
||||
if (!st->variant)
|
||||
return -ENODATA;
|
||||
|
||||
indio_dev->name = spi_get_device_id(spi)->name;
|
||||
indio_dev->channels = st->variant->channels;
|
||||
indio_dev->num_channels = st->variant->num_channels;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user