]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ASoC: wm8994: Fix potential deadlock
authorMarek Szyprowski <m.szyprowski@samsung.com>
Fri, 9 Dec 2022 09:16:57 +0000 (10:16 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:41:40 +0000 (11:41 +0100)
[ Upstream commit 643d0aa6031ae112e1a3742b3c4d730188baaf07 ]

Fix this by dropping wm8994->accdet_lock while calling
cancel_delayed_work_sync(&wm8994->mic_work) in wm1811_jackdet_irq().

Fixes: 6e5fc1d40133 ("ASoC: wm8994: Allow a delay between jack insertion and microphone detect")
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20221209091657.1183-1-m.szyprowski@samsung.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/soc/codecs/wm8994.c

index 6dbab3fc6537e679bcfe530fd541d1d0d4d543fc..4ae7ec8d71cdc1dccd4f457b5ebfbb0203dca355 100644 (file)
@@ -3711,7 +3711,12 @@ static irqreturn_t wm1811_jackdet_irq(int irq, void *data)
        } else {
                dev_dbg(component->dev, "Jack not detected\n");
 
+               /* Release wm8994->accdet_lock to avoid deadlock:
+                * cancel_delayed_work_sync() takes wm8994->mic_work internal
+                * lock and wm1811_mic_work takes wm8994->accdet_lock */
+               mutex_unlock(&wm8994->accdet_lock);
                cancel_delayed_work_sync(&wm8994->mic_work);
+               mutex_lock(&wm8994->accdet_lock);
 
                snd_soc_component_update_bits(component, WM8958_MICBIAS2,
                                    WM8958_MICB2_DISCH, WM8958_MICB2_DISCH);