Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH] ASoC: wm8962: Fix broken headset button caused by wrong guard constant
@ 2026-11-17  7:05 Chen Yuxi
  2026-11-17  7:30 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Chen Yuxi @ 2026-11-17  7:05 UTC (permalink / raw)
  To: broonie, lgirdwood
  Cc: ckeepax, patches, sebastian.krzyszkowiak, linux-sound,
	linux-kernel, chenyuxi19, yeweihua4, pulehui

Commit e59075211902 ("ASoC: wm8962: Don't report a microphone if
it's shorted to ground on plug") guards the mic short report by
testing wm8962->mic_status against WM8962_MICDET_STS.  But mic_status
stores the reported jack status, composed of SND_JACK_MICROPHONE and
SND_JACK_BTN_0, which never has WM8962_MICDET_STS set.  The guard is
therefore always true, so every mic short event reports nothing.

Pressing the button on a TRRS headset shorts the mic pin to ground,
which used to be reported as SND_JACK_BTN_0.  After that commit the
button press is silently dropped, breaking the headset button on all
wm8962 boards using the mic detect path.

Test mic_status against SND_JACK_MICROPHONE instead, restoring the
intended behaviour: suppress the report only when no microphone was
previously detected, i.e. a TRS plug in a TRRS socket.

Fixes: e59075211902 ("ASoC: wm8962: Don't report a microphone if it's shorted to ground on plug")
Cc: stable@vger.kernel.org
Signed-off-by: Chen Yuxi <chenyuxi19@huawei.com>
---
 sound/soc/codecs/wm8962.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index 148480e4124f..a4868685218b 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -3127,7 +3127,7 @@ static void wm8962_mic_work(struct work_struct *work)
 		/* Don't report a microphone if it's shorted right after
 		 * plugging in, as this may be a TRS plug in a TRRS socket.
 		 */
-		if (!(wm8962->mic_status & WM8962_MICDET_STS))
+		if (!(wm8962->mic_status & SND_JACK_MICROPHONE))
 			status = 0;
 	}
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ASoC: wm8962: Fix broken headset button caused by wrong guard constant
  2026-11-17  7:05 [PATCH] ASoC: wm8962: Fix broken headset button caused by wrong guard constant Chen Yuxi
@ 2026-11-17  7:30 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-17  7:30 UTC (permalink / raw)
  To: Chen Yuxi; +Cc: linux-sound

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] ASoC: wm8962: use-after-free in wm8962_mic_work() [1]
--

commit 8a0c59cf23261f48f72e00d3d31993d38fafcde5
Author: Chen Yuxi <chenyuxi19@huawei.com>

ASoC: wm8962: Fix broken headset button caused by wrong guard constant

This commit updates wm8962_mic_work() to test wm8962->mic_status against
SND_JACK_MICROPHONE instead of WM8962_MICDET_STS so that headset button
presses are reported when a microphone is already present.

> diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
> index 148480e4124fc..a4868685218b4 100644
> --- a/sound/soc/codecs/wm8962.c
> +++ b/sound/soc/codecs/wm8962.c
> @@ -3127,7 +3127,7 @@ static void wm8962_mic_work(struct work_struct *work)
>  		/* Don't report a microphone if it's shorted right after
>  		 * plugging in, as this may be a TRS plug in a TRRS socket.
>  		 */
> -		if (!(wm8962->mic_status & WM8962_MICDET_STS))
> +		if (!(wm8962->mic_status & SND_JACK_MICROPHONE))
>  			status = 0;
>  	}
>  

[Severity: Critical]
This problem wasn't introduced by this patch, but can wm8962_irq()
re-queue wm8962->mic_work [1] after wm8962_remove() cancels it?

The interrupt is requested during I2C probe and remains active across
ASoC component unbind, while wm8962_remove() cancels wm8962->mic_work
without masking the mic detection interrupts first:

CPU0                                  CPU1
wm8962_remove()
  cancel_delayed_work_sync(&wm8962->mic_work)
                                      wm8962_irq()
                                        queue_delayed_work(...,
                                          &wm8962->mic_work, ...)
  ... component freed ...
                                      wm8962_mic_work()
                                        snd_soc_component_read(component, ...)
                                          <-- use-after-free

[1] https://sashiko.dev/#/bug/linux-315f7aab-37ed-4fee-a0af-5ebeb7b5ed74

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261117070516.3861828-1-chenyuxi19@huawei.com?part=1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-17  7:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17  7:05 [PATCH] ASoC: wm8962: Fix broken headset button caused by wrong guard constant Chen Yuxi
2026-11-17  7:30 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox