All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tristan Madani" <tristmd@gmail.com>
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH v2 3/4] ASoC: twl6040: cancel headset jack work on component removal
Date: Thu, 29 Oct 2026 21:59:31 +0000	[thread overview]
Message-ID: <sashiko-outbox-190029@kernel.org> (raw)
In-Reply-To: <20261029212504.2997364-4-tristmd@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] ASoC: twl6040: work cancelled before free_irq() in twl6040_remove()
--

commit c1e273e65955a707961d70889d530cc54f85f31c
Author: Tristan Madani <tristmd@gmail.com>

ASoC: twl6040: cancel headset jack work on component removal

This commit adds cancel_delayed_work_sync() in twl6040_remove() to cancel the
headset jack detection delayed work upon component removal.

> diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c
> index 650836f9615fb..43feb660b635b 100644
> --- a/sound/soc/codecs/twl6040.c
> +++ b/sound/soc/codecs/twl6040.c
> @@ -1135,6 +1135,7 @@ static void twl6040_remove(struct snd_soc_component *component)
>  {
>  	struct twl6040_data *priv = snd_soc_component_get_drvdata(component);
>  
> +	cancel_delayed_work_sync(&priv->hs_jack.work);
>  	free_irq(priv->plug_irq, component);

[Severity: Critical]
Can priv->hs_jack.work be re-queued if priv->plug_irq fires after
cancel_delayed_work_sync() returns, but before free_irq() completes?

In sound/soc/codecs/twl6040.c, the threaded interrupt handler
twl6040_audio_handler() schedules the delayed work whenever priv->plug_irq
fires:

    queue_delayed_work(system_power_efficient_wq,
                       &priv->hs_jack.work, msecs_to_jiffies(200));

If twl6040_audio_handler() runs in the window between
cancel_delayed_work_sync() and free_irq() in twl6040_remove(),
priv->hs_jack.work will remain queued after removal completes, allowing
twl6040_accessory_work() to dereference priv and component after devres has
freed them.

Should free_irq(priv->plug_irq, component) be called before
cancel_delayed_work_sync(&priv->hs_jack.work), or should
disable_delayed_work_sync() be used instead?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261029212504.2997364-1-tristmd@gmail.com?part=3

  reply	other threads:[~2026-10-29 21:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29 21:25 [PATCH v2 0/4] ASoC: cancel pending delayed works on codec removal Tristan Madani
2026-10-29 21:25 ` [PATCH v2 1/4] ASoC: rt5668: cancel jack_detect_work on component removal Tristan Madani
2026-10-29 21:46   ` sashiko-bot
2026-10-29 21:25 ` [PATCH v2 2/4] ASoC: rt5659: " Tristan Madani
2026-10-29 21:56   ` sashiko-bot
2026-10-29 21:25 ` [PATCH v2 3/4] ASoC: twl6040: cancel headset jack work " Tristan Madani
2026-10-29 21:59   ` sashiko-bot [this message]
2026-10-29 21:25 ` [PATCH v2 4/4] ASoC: wm8994: drain delayed works on remove and probe error Tristan Madani
2026-10-29 22:34 ` [PATCH v2 0/4] ASoC: cancel pending delayed works on codec removal Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-190029@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tristmd@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.