[PATCH v6 0/4] ASoC: cancel pending delayed works on codec removal

From: Tristan Madani

Date: Mon Nov 02 2026 - 14:34:54 EST


From: Tristan Madani <tristan@xxxxxxxxxxxxxxxxxxx>

Several ASoC codec drivers schedule delayed works for jack detection
and microphone polling but do not cancel them on component removal,
leaving handlers that can run against freed memory.

This series adds proper teardown ordering in four codec drivers:
rt5668, rt5659, twl6040, and wm8994.

Changes since v5:
- Patch 4/4 (wm8994): add comments clarifying why mic_work is
cancelled twice (before and after jackdet_bootstrap), per
Charles Keepax review. No functional change.
- Patches 1-3/4: no changes.

Changes since v4:
- Patch 1/4 (rt5668): correct Fixes tag from nonexistent
e13da14e8543 to d59fb2856223. No code changes.
- Patches 2-4/4: no changes.

Changes since v3:
- rt5668 (1/4): track IRQ acquisition with irq_acquired flag.
- Patches 2-4/4: no code changes.

Changes since v2:
- rt5668 (1/4): also cancel jd_check_work, disable IRQ first.
- twl6040 (3/4): swap ordering -- free_irq() first.
- rt5659/wm8994: no code changes.

Changes since v1:
- Unified series per Mark Brown request.
- rt5659: guard cancel with jack_detect_work_inited flag.
- wm8994: cancel mic_work before and after jackdet_bootstrap.

Tristan Madani (4):
ASoC: rt5668: cancel delayed works on component removal
ASoC: rt5659: cancel jack_detect_work on component removal
ASoC: twl6040: cancel headset jack work on component removal
ASoC: wm8994: drain delayed works on remove and probe error

sound/soc/codecs/rt5659.c | 20 +++++++++++++++++++-
sound/soc/codecs/rt5659.h | 3 +++
sound/soc/codecs/rt5668.c | 20 +++++++++++++++++++-
sound/soc/codecs/twl6040.c | 1 +
sound/soc/codecs/wm8994.c | 16 ++++++++++++++++
5 files changed, 58 insertions(+), 2 deletions(-)

--
2.47.3