]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
iio: adc: ad7192: fix null pointer de-reference crash during probe
authorAlexandru Ardelean <alexandru.ardelean@analog.com>
Wed, 15 Apr 2020 05:58:03 +0000 (08:58 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 19 Apr 2020 16:50:03 +0000 (17:50 +0100)
commit8f2273b1e036f89bd04eb66bcb6f456eae8c98f1
tree0f9f95aa13fdc37731bf9bcc8ff2021435a772ea
parenta07479147be03d2450376ebaff9ea1a0682f25d6
iio: adc: ad7192: fix null pointer de-reference crash during probe

When the 'spi_device_id' table was removed, it omitted to cleanup/fix the
assignment:
   'indio_dev->name = spi_get_device_id(spi)->name;'

After that patch 'spi_get_device_id(spi)' returns NULL, so this crashes
during probe with null de-ref.

This change fixes this by introducing an ad7192_chip_info struct, and
defines all part-names [that should be assigned to indio_dev->name] in a
'ad7192_chip_info_tbl' table.

With this change, the old 'st->devid' is also moved to be a
'chip_info->chip_id'. And the old 'ID_AD719X' macros have been renamed to
'CHIPID_AD719X'. Tld identifiers have been re-purposed to be enum/index
values in the new 'ad7192_chip_info_tbl'.

This should fix the bug, and maintain the ABI for the 'indio_dev->name'
field.

Fixes: 66614ab2be38 ("staging: iio: adc: ad7192: removed spi_device_id")
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/ad7192.c