From: Myeonghun Pak <mhun512@gmail.com>
To: Oder Chiou <oder_chiou@realtek.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: [PATCH v2] ASoC: rt5663: Stop jack work on probe failure and unbind
Date: Tue, 17 Nov 2026 20:40:51 -0500 [thread overview]
Message-ID: <20261118014051.75468-1-mhun512@gmail.com> (raw)
rt5663 registers its jack IRQ before registering the ASoC component.
If component registration fails, freeing the IRQ leaves any pending
or running jack work in place while devres releases rt5663_priv.
I2C removal can leave the same work behind.
Stop the IRQ handler before disabling and draining both delayed
works on component registration failure and I2C removal. Stop
jack_detect_work first because it can queue jd_unplug_work. Keep
both works disabled through device teardown because ASoC link
cleanup can still call set_jack() after I2C remove returns.
Send earlier probe failures directly to regulator cleanup, before
the driver has registered an IRQ or started jack detection.
Found by a static analysis tool under development.
Fixes: df7c52168ee1 ("ASoC: add rt5663 codec driver")
Cc: stable@vger.kernel.org # 6.10+
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
---
Changes in v2:
- Drop the duplicate subject from the body (Mark Brown).
- Cover component registration failure after IRQ setup (Mark Brown).
- Share I2C teardown and keep both works disabled through component
unregistration to block late set_jack() enqueues.
No hardware test.
sound/soc/codecs/rt5663.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c
index 58b165e8b6e12537196a775338de1da1667ad82a..5e95ab2666594ea1a8f2a59338cbd513c8c97c4e 100644
--- a/sound/soc/codecs/rt5663.c
+++ b/sound/soc/codecs/rt5663.c
@@ -3520,6 +3520,16 @@ static int rt5663_parse_dp(struct rt5663_priv *rt5663, struct device *dev)
return 0;
}
+static void rt5663_stop_jack_work(struct rt5663_priv *rt5663)
+{
+ if (rt5663->irq)
+ free_irq(rt5663->irq, rt5663);
+
+ /* Jack detection can queue unplug work. */
+ disable_delayed_work_sync(&rt5663->jack_detect_work);
+ disable_delayed_work_sync(&rt5663->jd_unplug_work);
+}
+
static int rt5663_i2c_probe(struct i2c_client *i2c)
{
struct rt5663_platform_data *pdata = dev_get_platdata(&i2c->dev);
@@ -3724,19 +3734,13 @@ static int rt5663_i2c_probe(struct i2c_client *i2c)
rt5663_dai, ARRAY_SIZE(rt5663_dai));
if (ret)
- goto err_enable;
+ goto err_jack_work;
return 0;
-
- /*
- * Error after enabling regulators should goto err_enable
- * to disable regulators.
- */
+err_jack_work:
+ rt5663_stop_jack_work(rt5663);
err_enable:
- if (i2c->irq)
- free_irq(i2c->irq, rt5663);
-
regulator_bulk_disable(ARRAY_SIZE(rt5663->supplies), rt5663->supplies);
return ret;
}
@@ -3745,8 +3749,7 @@ static void rt5663_i2c_remove(struct i2c_client *i2c)
{
struct rt5663_priv *rt5663 = i2c_get_clientdata(i2c);
- if (i2c->irq)
- free_irq(i2c->irq, rt5663);
+ rt5663_stop_jack_work(rt5663);
regulator_bulk_disable(ARRAY_SIZE(rt5663->supplies), rt5663->supplies);
}
base-commit: fcfcd6db32adbdfe81c1ded257200e3ea6815d9a
reply other threads:[~2026-11-18 1:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261118014051.75468-1-mhun512@gmail.com \
--to=mhun512@gmail.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=oder_chiou@realtek.com \
--cc=perex@perex.cz \
--cc=stable@vger.kernel.org \
--cc=tiwai@suse.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®