iio: adc: ad7192: properly check spi_get_device_match_data()
Subsystems (3)
Nuno Sa
maintainerPATCH 1/1 iio: adc: ad7192: properly check spi_get_device_match_data()
spi_get_device_match_data() can return a NULL pointer. Hence, let's check for it.
Signed-off-by Nuno Sa <[email protected]>
--- drivers/iio/adc/ad7192.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iio/adc/ad7192.c +3 -0
@@ -1394,6 +1394,9 @@ static int ad7192_probe(struct spi_device *spi) st->int_vref_mv = ret == -ENODEV ? avdd_mv : ret /MILLI ; st->chip_info =spi_get_device_match_data (spi); +if (!st->chip_info) +return -ENODEV ; + indio_dev->name = st->chip_info->name; indio_dev->modes =INDIO_DIRECT_MODE ; indio_dev->info = st->chip_info->info;
---
base-commit: 465644ac29536d10178b5ca4684d0b84765b9fa4
change-id: 20241014-fix-error-check-d34fde9780a2 --
Thanks!
- Nuno Sá
Quoted 4 lines · On Mon, 14 Oct 2024 17:01:21 +0200 Nuno Sa <[email protected]> wrote:
spi_get_device_match_data()can return a NULL pointer. Hence, let's check for it.Signed-off-by Nuno Sa <[email protected]>
Applied.
Quoted 27 lines
--- drivers/iio/adc/ad7192.c | 3 +++ 1 file changed, 3 insertions(+)drivers/iio/adc/ad7192.c +3
-1@@ -1394,6 +1394,9 @@ static int ad7192_probe(struct spi_device *spi) st->int_vref_mv = ret == -ENODEV ? avdd_mv : ret /MILLI ; st->chip_info =spi_get_device_match_data (spi); +if (!st->chip_info) +return -ENODEV ; + indio_dev->name = st->chip_info->name; indio_dev->modes =INDIO_DIRECT_MODE ; indio_dev->info = st->chip_info->info; ---base-commit:
465644ac29536d10178b5ca4684d0b84765b9fa4
change-id: 20241014-fix-error-check-d34fde9780a2 --Thanks!
- Nuno Sá