• Alexandru Ardelean's avatar
    iio: adc: ad7192: fix null pointer de-reference crash during probe · 8f2273b1
    Alexandru Ardelean authored
    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: 66614ab2 ("staging: iio: adc: ad7192: removed spi_device_id")
    Signed-off-by: default avatarAlexandru Ardelean <alexandru.ardelean@analog.com>
    Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
    8f2273b1
ad7192.c 29.5 KB