ASoC: rt5668: initialize calibrate_mutex before first use
Subsystems (4)
PATCH 1/1 ASoC: rt5668: initialize calibrate_mutex before first use
From: Tristan Madani <[email protected]>
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.
--- sound/soc/codecs/rt5668.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/rt5668.c +2 -2
@@ -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
Signature · 1 line
2.47.3
Mark Brown
maintainerQuoted 1 line · Tristan Madani
ASoC: rt5668: initialize
calibrate_mutexbefore first use
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.5
Thanks!
[1/1] ASoC: rt5668: initialize calibrate_mutex before first use
https://git.kernel.org/broonie/sound/c/00e80a5f6dcd
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark