]> www.infradead.org Git - users/dwmw2/linux.git/commit
iio: adc: ina2xx: avoid kthread_stop() with stale task_struct
authorAkinobu Mita <akinobu.mita@gmail.com>
Sun, 24 Jun 2018 15:05:21 +0000 (00:05 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Oct 2018 23:59:03 +0000 (16:59 -0700)
commitc9bcfbebca4074dfb6db597f00747d1106cb08d2
tree6040c6ad51148e3c16c4bdbda72a41cd18626bf9
parentd08aa810ddd189e2e8e84b1a0ce09621dfd35cd1
iio: adc: ina2xx: avoid kthread_stop() with stale task_struct

[ Upstream commit 7d6cd21d82bacab2d1786fe5e989e4815b75d9a3 ]

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: Akinobu Mita <akinobu.mita@gmail.com>
Fixes: c43a102e67db ("iio: ina2xx: add support for TI INA2xx Power Monitors")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/adc/ina2xx-adc.c