From: Tristan Madani <tristmd@gmail.com>
To: Oder Chiou <oder_chiou@realtek.com>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org,
Tristan Madani <tristan@talencesecurity.com>
Subject: [PATCH] ASoC: rt5668: initialize calibrate_mutex before first use
Date: Wed, 11 Nov 2026 11:49:19 +0000 [thread overview]
Message-ID: <20261111114919.95639-1-tristmd@gmail.com> (raw)
From: Tristan Madani <tristan@talencesecurity.com>
rt5668_calibrate() is called during i2c_probe() and takes
calibrate_mutex. However, mutex_init() for that mutex is not called
until later in the probe sequence, after the INIT_DELAYED_WORK calls.
This means the first calibration locks an uninitialized mutex.
While this works by accident because devm_kzalloc zeroes the struct
memory, it is incorrect and triggers warnings with
CONFIG_DEBUG_MUTEXES=y.
Move the mutex_init() call to before rt5668_calibrate() so the mutex
is properly initialized before its first use.
Fixes: d59fb2856223 ("ASoC: rt5668: add rt5668B codec driver")
Cc: stable@vger.kernel.org
Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
---
sound/soc/codecs/rt5668.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/rt5668.c b/sound/soc/codecs/rt5668.c
index cd6245d6b91af..6748bcc63ac39 100644
--- a/sound/soc/codecs/rt5668.c
+++ b/sound/soc/codecs/rt5668.c
@@ -2490,6 +2490,8 @@ static int rt5668_i2c_probe(struct i2c_client *i2c)
rt5668_reset(rt5668->regmap);
+ mutex_init(&rt5668->calibrate_mutex);
+
rt5668_calibrate(rt5668);
regmap_write(rt5668->regmap, RT5668_DEPOP_1, 0x0000);
@@ -2547,8 +2549,6 @@ static int rt5668_i2c_probe(struct i2c_client *i2c)
INIT_DELAYED_WORK(&rt5668->jd_check_work,
rt5668_jd_check_handler);
- mutex_init(&rt5668->calibrate_mutex);
-
if (i2c->irq) {
ret = devm_request_threaded_irq(&i2c->dev, i2c->irq, NULL,
rt5668_irq, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING
--
2.47.3
reply other threads:[~2026-11-11 11:49 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=20261111114919.95639-1-tristmd@gmail.com \
--to=tristmd@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 \
--cc=tristan@talencesecurity.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®