]> www.infradead.org Git - users/willy/xarray.git/commit
iio: light: opt3001: fix deadlock due to concurrent flag access
authorLuca Ceresoli <luca.ceresoli@bootlin.com>
Fri, 21 Mar 2025 18:10:00 +0000 (19:10 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 7 Apr 2025 18:32:49 +0000 (19:32 +0100)
commitf063a28002e3350088b4577c5640882bf4ea17ea
treeb1397e266f7e86ba27f8b3c4ed862bbe7d6b8ad2
parent82c51ac74071b80b3199d9e200ae1a5399f4deb0
iio: light: opt3001: fix deadlock due to concurrent flag access

The threaded IRQ function in this driver is reading the flag twice: once to
lock a mutex and once to unlock it. Even though the code setting the flag
is designed to prevent it, there are subtle cases where the flag could be
true at the mutex_lock stage and false at the mutex_unlock stage. This
results in the mutex not being unlocked, resulting in a deadlock.

Fix it by making the opt3001_irq() code generally more robust, reading the
flag into a variable and using the variable value at both stages.

Fixes: 94a9b7b1809f ("iio: light: add support for TI's opt3001 light sensor")
Cc: stable@vger.kernel.org
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Link: https://patch.msgid.link/20250321-opt3001-irq-fix-v1-1-6c520d851562@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/light/opt3001.c