]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ti-linux-kernel/ti-linux-kernel-next.git/commit
iio: light: opt3001: fix mutex unlock race
authorDavid Frey <dpfrey@gmail.com>
Thu, 19 Sep 2019 22:54:18 +0000 (15:54 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Oct 2019 21:46:57 +0000 (14:46 -0700)
commit82c1d301c9f78f21b6804af2185af2ba5904e5cd
treebc203d995466607da660e015e0d5c3942917acdd
parentd340e0ccb8158bf2fa4d4b75584f92b502dca3af
iio: light: opt3001: fix mutex unlock race

commit 82f3015635249a8c8c45bac303fd84905066f04f upstream.

When an end-of-conversion interrupt is received after performing a
single-shot reading of the light sensor, the driver was waking up the
result ready queue before checking opt->ok_to_ignore_lock to determine
if it should unlock the mutex. The problem occurred in the case where
the other thread woke up and changed the value of opt->ok_to_ignore_lock
to false prior to the interrupt thread performing its read of the
variable. In this case, the mutex would be unlocked twice.

Signed-off-by: David Frey <dpfrey@gmail.com>
Reviewed-by: Andreas Dannenberg <dannenberg@ti.com>
Fixes: 94a9b7b1809f ("iio: light: add support for TI's opt3001 light sensor")
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/light/opt3001.c