FAILED: patch "[PATCH] iio: light: opt3001: fix deadlock due to concurrent flag" failed to apply to 6.1-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x f063a28002e3350088b4577c5640882bf4ea17ea
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2025051216-daily-camera-c269@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From f063a28002e3350088b4577c5640882bf4ea17ea Mon Sep 17 00:00:00 2001
From: Luca Ceresoli <[email protected]>
Date: Fri, 21 Mar 2025 19:10:00 +0100
Subject: [PATCH] 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.
drivers/iio/light/opt3001.c +3 -2
@@ -788,8 +788,9 @@ static irqreturn_t opt3001_irq(int irq, void *_iio)int ret;bool wake_result_ready_queue = false;enum iio_chan_type chan_type = opt->chip_info->chan_type; +bool ok_to_ignore_lock = opt->ok_to_ignore_lock; -if (!opt->ok_to_ignore_lock) +if (!ok_to_ignore_lock)mutex_lock (&opt->lock); ret =i2c_smbus_read_word_swapped (opt->client,OPT3001_CONFIGURATION );
@@ -826,7 +827,7 @@ static irqreturn_t opt3001_irq(int irq, void *_iio) } out: -if (!opt->ok_to_ignore_lock) +if (!ok_to_ignore_lock)mutex_unlock (&opt->lock);if (wake_result_ready_queue)
Sasha Levin
maintainerPATCH 1/1 iio: light: opt3001: fix deadlock due to concurrent flag access
From: Luca Ceresoli <[email protected]>
[ Upstream commit f063a28002e3350088b4577c5640882bf4ea17ea ]
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.
--- drivers/iio/light/opt3001.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/iio/light/opt3001.c +3 -2
@@ -692,8 +692,9 @@ static irqreturn_t opt3001_irq(int irq, void *_iio)struct opt3001 *opt =iio_priv (iio);int ret;bool wake_result_ready_queue = false; +bool ok_to_ignore_lock = opt->ok_to_ignore_lock; -if (!opt->ok_to_ignore_lock) +if (!ok_to_ignore_lock)mutex_lock (&opt->lock); ret =i2c_smbus_read_word_swapped (opt->client,OPT3001_CONFIGURATION );
@@ -730,7 +731,7 @@ static irqreturn_t opt3001_irq(int irq, void *_iio) } out: -if (!opt->ok_to_ignore_lock) +if (!ok_to_ignore_lock)mutex_unlock (&opt->lock);if (wake_result_ready_queue)
Signature · 1 line
2.50.1