Skip to content
  • Akinobu Mita's avatar
    iio: adc: ina2xx: avoid kthread_stop() with stale task_struct · 7d6cd21d
    Akinobu Mita authored
    
    
    When the buffer is enabled for ina2xx driver, a dedicated kthread is
    invoked to capture mesurement data.  When the buffer is disabled, the
    kthread is stopped.
    
    However if the kthread gets register access errors, it immediately exits
    and when the malfunctional buffer is disabled, the stale task_struct
    pointer is accessed as there is no kthread to be stopped.
    
    A similar issue in the usbip driver is prevented by kthread_get_run and
    kthread_stop_put helpers by increasing usage count of the task_struct.
    This change applies the same solution.
    
    Cc: Stefan Brüns <stefan.bruens@rwth-aachen.de>
    Cc: Jonathan Cameron <jic23@kernel.org>
    Signed-off-by: default avatarAkinobu Mita <akinobu.mita@gmail.com>
    Fixes: c43a102e
    
     ("iio: ina2xx: add support for TI INA2xx Power Monitors")
    Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
    7d6cd21d