* [PATCH 0/6] ASoC: codecs: Fix runtime PM handling on probe failure and unbind
@ 2026-12-01 19:06 Arina Kharlamova via B4 Relay
2026-12-01 19:07 ` [PATCH 1/6] ASoC: cs35l33: Disable runtime PM on component registration failure Arina Kharlamova via B4 Relay
` (5 more replies)
0 siblings, 6 replies; 8+ messages in thread
From: Arina Kharlamova via B4 Relay @ 2026-12-01 19:06 UTC (permalink / raw)
To: David Rhodes, Richard Fitzgerald, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, Charles Keepax, Zhang Yi,
Oder Chiou, ChiYuan Huang, Srinivas Kandagatla
Cc: linux-sound, patches, linux-arm-msm, Arina Kharlamova
Six codec drivers leave runtime PM enabled, or keep a runtime PM
reference, when probe fails or when the driver is unbound. In five of
them a later probe then warns about an unbalanced pm_runtime_enable().
I found these with spec2patch. I model-checked the probe and remove
paths of each driver with CBMC against formal specifications of the
kernel APIs they call. The specifications are checked against the kernel
source, and some of them are proved in Rocq against a transcription of
the kernel code. I also checked lock usage separately. With the help of
an AI coding assistant (Claude); I reviewed the analysis and the fix.
Compile-tested only, not tested on hardware.
---
Arina Kharlamova (6):
ASoC: cs35l33: Disable runtime PM on component registration failure
ASoC: cs35l34: Disable runtime PM on component registration failure
ASoC: cs47l24: Disable runtime PM on probe failure
ASoC: es9356: disable runtime PM in remove unconditionally
ASoC: codecs: rtq9128: Drop runtime PM reference on probe errors
ASoC: codecs: wsa881x: Disable runtime PM on unbind
sound/soc/codecs/cs35l33.c | 1 +
sound/soc/codecs/cs35l34.c | 1 +
sound/soc/codecs/cs47l24.c | 4 +++-
sound/soc/codecs/es9356.c | 3 +--
sound/soc/codecs/rtq9128.c | 7 ++++---
sound/soc/codecs/wsa881x.c | 5 ++++-
6 files changed, 14 insertions(+), 7 deletions(-)
---
base-commit: 20ee6031645dbed8ddf8f4833edf415f3760607f
change-id: 20261201-s2p-asoc-rpm-773b7fd87b87
Best regards,
--
Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/6] ASoC: cs35l33: Disable runtime PM on component registration failure
2026-12-01 19:06 [PATCH 0/6] ASoC: codecs: Fix runtime PM handling on probe failure and unbind Arina Kharlamova via B4 Relay
@ 2026-12-01 19:07 ` Arina Kharlamova via B4 Relay
2026-12-01 19:07 ` [PATCH 2/6] ASoC: cs35l34: " Arina Kharlamova via B4 Relay
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Arina Kharlamova via B4 Relay @ 2026-12-01 19:07 UTC (permalink / raw)
To: David Rhodes, Richard Fitzgerald, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, Charles Keepax, Zhang Yi,
Oder Chiou, ChiYuan Huang, Srinivas Kandagatla
Cc: linux-sound, patches, linux-arm-msm, Arina Kharlamova
From: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
cs35l33_i2c_probe() enables runtime PM before it registers the
component, but the error path of the registration does not disable it
again. remove() is not called after a failed probe, so the next probe
warns about an unbalanced pm_runtime_enable().
Disable runtime PM on that error path.
Fixes: 3333cb7187b9 ("ASoC: cs35l33: Initial commit of the cs35l33 CODEC driver.")
Signed-off-by: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
---
sound/soc/codecs/cs35l33.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/sound/soc/codecs/cs35l33.c b/sound/soc/codecs/cs35l33.c
index 40a3a7449a66..f3d0843fb5fd 100644
--- a/sound/soc/codecs/cs35l33.c
+++ b/sound/soc/codecs/cs35l33.c
@@ -1245,6 +1245,7 @@ static int cs35l33_i2c_probe(struct i2c_client *i2c_client)
if (ret < 0) {
dev_err(&i2c_client->dev, "%s: Register component failed\n",
__func__);
+ pm_runtime_disable(&i2c_client->dev);
goto err_enable;
}
--
Git-157)
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/6] ASoC: cs35l34: Disable runtime PM on component registration failure
2026-12-01 19:06 [PATCH 0/6] ASoC: codecs: Fix runtime PM handling on probe failure and unbind Arina Kharlamova via B4 Relay
2026-12-01 19:07 ` [PATCH 1/6] ASoC: cs35l33: Disable runtime PM on component registration failure Arina Kharlamova via B4 Relay
@ 2026-12-01 19:07 ` Arina Kharlamova via B4 Relay
2026-12-01 19:07 ` [PATCH 3/6] ASoC: cs47l24: Disable runtime PM on probe failure Arina Kharlamova via B4 Relay
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Arina Kharlamova via B4 Relay @ 2026-12-01 19:07 UTC (permalink / raw)
To: David Rhodes, Richard Fitzgerald, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, Charles Keepax, Zhang Yi,
Oder Chiou, ChiYuan Huang, Srinivas Kandagatla
Cc: linux-sound, patches, linux-arm-msm, Arina Kharlamova
From: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
cs35l34_i2c_probe() enables runtime PM before it registers the
component, but the error path of the registration does not disable it
again. remove() is not called after a failed probe, so the next probe
warns about an unbalanced pm_runtime_enable().
Disable runtime PM on that error path.
Fixes: c1124c09e103 ("ASoC: cs35l34: Initial commit of the cs35l34 CODEC driver.")
Signed-off-by: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
---
sound/soc/codecs/cs35l34.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/sound/soc/codecs/cs35l34.c b/sound/soc/codecs/cs35l34.c
index 26ac3c2d6e9c..3ba52b23f772 100644
--- a/sound/soc/codecs/cs35l34.c
+++ b/sound/soc/codecs/cs35l34.c
@@ -1093,6 +1093,7 @@ static int cs35l34_i2c_probe(struct i2c_client *i2c_client)
if (ret < 0) {
dev_err(&i2c_client->dev,
"%s: Register component failed\n", __func__);
+ pm_runtime_disable(&i2c_client->dev);
goto err_reset;
}
--
Git-157)
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/6] ASoC: cs47l24: Disable runtime PM on probe failure
2026-12-01 19:06 [PATCH 0/6] ASoC: codecs: Fix runtime PM handling on probe failure and unbind Arina Kharlamova via B4 Relay
2026-12-01 19:07 ` [PATCH 1/6] ASoC: cs35l33: Disable runtime PM on component registration failure Arina Kharlamova via B4 Relay
2026-12-01 19:07 ` [PATCH 2/6] ASoC: cs35l34: " Arina Kharlamova via B4 Relay
@ 2026-12-01 19:07 ` Arina Kharlamova via B4 Relay
2026-12-01 19:07 ` [PATCH 4/6] ASoC: es9356: disable runtime PM in remove unconditionally Arina Kharlamova via B4 Relay
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Arina Kharlamova via B4 Relay @ 2026-12-01 19:07 UTC (permalink / raw)
To: David Rhodes, Richard Fitzgerald, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, Charles Keepax, Zhang Yi,
Oder Chiou, ChiYuan Huang, Srinivas Kandagatla
Cc: linux-sound, patches, linux-arm-msm, Arina Kharlamova
From: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
cs47l24_probe() enables runtime PM and then requests the DSP IRQ and
registers the component. If arizona_request_irq() or
devm_snd_soc_register_component() fails, probe returns the error
without disabling runtime PM. The remove callback is not called after
a failed probe, so runtime PM stays enabled and a later probe of the
device gets the "Unbalanced pm_runtime_enable!" warning.
Disable runtime PM on the probe error paths, as wm5110_probe() does.
Fixes: 6610550c4c26 ("ASoC: cs47l24: Add driver for Cirrus Logic CS47L24 and WM1831 codecs")
Signed-off-by: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
---
sound/soc/codecs/cs47l24.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/cs47l24.c b/sound/soc/codecs/cs47l24.c
index 744a610cd1af..95636e2df08d 100644
--- a/sound/soc/codecs/cs47l24.c
+++ b/sound/soc/codecs/cs47l24.c
@@ -1278,7 +1278,7 @@ static int cs47l24_probe(struct platform_device *pdev)
cs47l24);
if (ret != 0) {
dev_err(&pdev->dev, "Failed to request DSP IRQ: %d\n", ret);
- return ret;
+ goto err_pm_disable;
}
ret = arizona_set_irq_wake(arizona, ARIZONA_IRQ_DSP_IRQ1, 1);
@@ -1312,6 +1312,8 @@ err_spk_irqs:
err_dsp_irq:
arizona_set_irq_wake(arizona, ARIZONA_IRQ_DSP_IRQ1, 0);
arizona_free_irq(arizona, ARIZONA_IRQ_DSP_IRQ1, cs47l24);
+err_pm_disable:
+ pm_runtime_disable(&pdev->dev);
return ret;
}
--
Git-157)
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/6] ASoC: es9356: disable runtime PM in remove unconditionally
2026-12-01 19:06 [PATCH 0/6] ASoC: codecs: Fix runtime PM handling on probe failure and unbind Arina Kharlamova via B4 Relay
` (2 preceding siblings ...)
2026-12-01 19:07 ` [PATCH 3/6] ASoC: cs47l24: Disable runtime PM on probe failure Arina Kharlamova via B4 Relay
@ 2026-12-01 19:07 ` Arina Kharlamova via B4 Relay
2026-12-01 19:22 ` sashiko-bot
2026-12-01 19:07 ` [PATCH 5/6] ASoC: codecs: rtq9128: Drop runtime PM reference on probe errors Arina Kharlamova via B4 Relay
2026-12-01 19:07 ` [PATCH 6/6] ASoC: codecs: wsa881x: Disable runtime PM on unbind Arina Kharlamova via B4 Relay
5 siblings, 1 reply; 8+ messages in thread
From: Arina Kharlamova via B4 Relay @ 2026-12-01 19:07 UTC (permalink / raw)
To: David Rhodes, Richard Fitzgerald, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, Charles Keepax, Zhang Yi,
Oder Chiou, ChiYuan Huang, Srinivas Kandagatla
Cc: linux-sound, patches, linux-arm-msm, Arina Kharlamova
From: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
es9356_sdca_init() enables runtime PM at probe time, before the codec
is enumerated. es9356_sdw_remove() calls pm_runtime_disable() only if
first_hw_init is set, and that flag is set in es9356_sdca_io_init()
once the codec has attached for the first time.
If the driver is unbound before the codec ever attached, runtime PM
stays enabled on the SoundWire device. The next probe calls
pm_runtime_enable() again and the PM core prints "Unbalanced
pm_runtime_enable!".
Disable runtime PM in remove unconditionally, as max98373-sdw and
rt711-sdca do.
Fixes: 5d9cb740cd38 ("ASoC: es9356-sdca: Add ES9356 SDCA driver")
Signed-off-by: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
---
sound/soc/codecs/es9356.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/sound/soc/codecs/es9356.c b/sound/soc/codecs/es9356.c
index cc69336dff79..267db423b691 100644
--- a/sound/soc/codecs/es9356.c
+++ b/sound/soc/codecs/es9356.c
@@ -1150,8 +1150,7 @@ static void es9356_sdw_remove(struct sdw_slave *slave)
cancel_delayed_work_sync(&es9356->button_detect_work);
}
- if (es9356->first_hw_init)
- pm_runtime_disable(&slave->dev);
+ pm_runtime_disable(&slave->dev);
mutex_destroy(&es9356->disable_irq_lock);
mutex_destroy(&es9356->pde_lock);
--
Git-157)
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/6] ASoC: codecs: rtq9128: Drop runtime PM reference on probe errors
2026-12-01 19:06 [PATCH 0/6] ASoC: codecs: Fix runtime PM handling on probe failure and unbind Arina Kharlamova via B4 Relay
` (3 preceding siblings ...)
2026-12-01 19:07 ` [PATCH 4/6] ASoC: es9356: disable runtime PM in remove unconditionally Arina Kharlamova via B4 Relay
@ 2026-12-01 19:07 ` Arina Kharlamova via B4 Relay
2026-12-01 19:07 ` [PATCH 6/6] ASoC: codecs: wsa881x: Disable runtime PM on unbind Arina Kharlamova via B4 Relay
5 siblings, 0 replies; 8+ messages in thread
From: Arina Kharlamova via B4 Relay @ 2026-12-01 19:07 UTC (permalink / raw)
To: David Rhodes, Richard Fitzgerald, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, Charles Keepax, Zhang Yi,
Oder Chiou, ChiYuan Huang, Srinivas Kandagatla
Cc: linux-sound, patches, linux-arm-msm, Arina Kharlamova
From: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
rtq9128_component_probe() takes a runtime PM reference with
pm_runtime_resume_and_get() and then writes the init table and, for
RTQ9154, the AUTO ULQM register. If one of these
snd_soc_component_write() calls fails, the function returns without
calling pm_runtime_put(). The usage count stays raised and the device
cannot runtime suspend.
Leave through a common exit that drops the reference on these error
paths as well.
Fixes: 736064c64cf3 ("ASoC: codecs: Add Richtek rtq9128 audio amplifier support")
Fixes: 6be9ea62afed ("ASoC: codecs: rtq9128: Add compatible changes for rtq9154")
Signed-off-by: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
---
sound/soc/codecs/rtq9128.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/sound/soc/codecs/rtq9128.c b/sound/soc/codecs/rtq9128.c
index a6d4a81ff181..8635ccba39a5 100644
--- a/sound/soc/codecs/rtq9128.c
+++ b/sound/soc/codecs/rtq9128.c
@@ -484,7 +484,7 @@ static int rtq9128_component_probe(struct snd_soc_component *comp)
for (i = 0, curr = table; i < table_size; i++, curr++) {
ret = snd_soc_component_write(comp, curr->reg, curr->val);
if (ret < 0)
- return ret;
+ goto out_put;
}
@@ -492,13 +492,14 @@ static int rtq9128_component_probe(struct snd_soc_component *comp)
/* Enable RTQ9154 Specific AUTO ULQM feature */
ret = snd_soc_component_write(comp, RTQ9154_REG_AUTOULQM, RTQ9154_AUTOULQM_VAL);
if (ret < 0)
- return ret;
+ goto out_put;
}
+out_put:
pm_runtime_mark_last_busy(comp->dev);
pm_runtime_put(comp->dev);
- return 0;
+ return ret;
}
static const struct snd_soc_component_driver rtq9128_comp_driver = {
--
Git-157)
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 6/6] ASoC: codecs: wsa881x: Disable runtime PM on unbind
2026-12-01 19:06 [PATCH 0/6] ASoC: codecs: Fix runtime PM handling on probe failure and unbind Arina Kharlamova via B4 Relay
` (4 preceding siblings ...)
2026-12-01 19:07 ` [PATCH 5/6] ASoC: codecs: rtq9128: Drop runtime PM reference on probe errors Arina Kharlamova via B4 Relay
@ 2026-12-01 19:07 ` Arina Kharlamova via B4 Relay
5 siblings, 0 replies; 8+ messages in thread
From: Arina Kharlamova via B4 Relay @ 2026-12-01 19:07 UTC (permalink / raw)
To: David Rhodes, Richard Fitzgerald, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, Charles Keepax, Zhang Yi,
Oder Chiou, ChiYuan Huang, Srinivas Kandagatla
Cc: linux-sound, patches, linux-arm-msm, Arina Kharlamova
From: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
wsa881x_probe() enables runtime PM, but the driver has no remove
callback and nothing disables it on unbind or when
devm_snd_soc_register_component() fails. Runtime PM stays enabled on
the SoundWire device and the next probe prints "Unbalanced
pm_runtime_enable!".
Use devm_pm_runtime_enable(), as wsa883x and wsa884x do. Runtime PM is
then disabled after the component is unregistered and before the
regmap and the powerdown GPIO used by wsa881x_runtime_suspend() are
released.
Fixes: 8dd552458361 ("ASoC: codecs: wsa881x: add runtime pm support")
Signed-off-by: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
---
sound/soc/codecs/wsa881x.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/wsa881x.c b/sound/soc/codecs/wsa881x.c
index f6cba55288e0..d2599b142199 100644
--- a/sound/soc/codecs/wsa881x.c
+++ b/sound/soc/codecs/wsa881x.c
@@ -1110,6 +1110,7 @@ static int wsa881x_probe(struct sdw_slave *pdev,
{
struct wsa881x_priv *wsa881x;
struct device *dev = &pdev->dev;
+ int ret;
wsa881x = devm_kzalloc_obj(dev, *wsa881x);
if (!wsa881x)
@@ -1149,7 +1150,9 @@ static int wsa881x_probe(struct sdw_slave *pdev,
pm_runtime_use_autosuspend(dev);
pm_runtime_mark_last_busy(dev);
pm_runtime_set_active(dev);
- pm_runtime_enable(dev);
+ ret = devm_pm_runtime_enable(dev);
+ if (ret)
+ return ret;
return devm_snd_soc_register_component(dev,
&wsa881x_component_drv,
--
Git-157)
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 4/6] ASoC: es9356: disable runtime PM in remove unconditionally
2026-12-01 19:07 ` [PATCH 4/6] ASoC: es9356: disable runtime PM in remove unconditionally Arina Kharlamova via B4 Relay
@ 2026-12-01 19:22 ` sashiko-bot
0 siblings, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-12-01 19:22 UTC (permalink / raw)
To: Arina Kharlamova; +Cc: linux-sound
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] ASoC: es9356: use-after-free in es9356_sdw_remove() [1]
--
commit 528ed0d483b59e2d6fe68475201f8a4df4ccb91d
Author: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
ASoC: es9356: disable runtime PM in remove unconditionally
This commit removes the first_hw_init check before pm_runtime_disable()
in es9356_sdw_remove() so runtime PM is always disabled when the driver
is unbound.
> diff --git a/sound/soc/codecs/es9356.c b/sound/soc/codecs/es9356.c
> index cc69336dff79e..267db423b6913 100644
> --- a/sound/soc/codecs/es9356.c
> +++ b/sound/soc/codecs/es9356.c
> @@ -1150,8 +1150,7 @@ static void es9356_sdw_remove(struct sdw_slave *slave)
> cancel_delayed_work_sync(&es9356->button_detect_work);
> }
>
> - if (es9356->first_hw_init)
> - pm_runtime_disable(&slave->dev);
> + pm_runtime_disable(&slave->dev);
[Severity: Critical]
This problem wasn't introduced by this patch, but can guarding the work
cancellation above with es9356->hw_init cause a use-after-free [1]
when unattach races with driver unbind?
When es9356_sdw_update_status() handles SDW_SLAVE_UNATTACHED, it clears
es9356->hw_init before canceling interrupt_handle_work and
button_detect_work:
CPU0 CPU1
es9356_sdw_update_status()
es9356->hw_init = false;
es9356_sdw_remove()
if (es9356->hw_init) // false
// devres frees es9356
cancel_delayed_work_sync(...) <-- use-after-free
Because es9356_sdw_remove() skips canceling the delayed works and returns,
devres frees es9356 while es9356_sdw_update_status() or the pending work
handlers still access it. Both delayed works are initialized in
es9356_sdca_init() at probe time, so es9356_sdw_remove() can cancel them
unconditionally.
[1] https://sashiko.dev/#/bug/linux-70b198a2-7241-42b4-a17a-72e02648f7c0
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201-s2p-asoc-rpm-v1-0-477189293ad4@mbzuai.ac.ae?part=4
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-12-01 19:22 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 19:06 [PATCH 0/6] ASoC: codecs: Fix runtime PM handling on probe failure and unbind Arina Kharlamova via B4 Relay
2026-12-01 19:07 ` [PATCH 1/6] ASoC: cs35l33: Disable runtime PM on component registration failure Arina Kharlamova via B4 Relay
2026-12-01 19:07 ` [PATCH 2/6] ASoC: cs35l34: " Arina Kharlamova via B4 Relay
2026-12-01 19:07 ` [PATCH 3/6] ASoC: cs47l24: Disable runtime PM on probe failure Arina Kharlamova via B4 Relay
2026-12-01 19:07 ` [PATCH 4/6] ASoC: es9356: disable runtime PM in remove unconditionally Arina Kharlamova via B4 Relay
2026-12-01 19:22 ` sashiko-bot
2026-12-01 19:07 ` [PATCH 5/6] ASoC: codecs: rtq9128: Drop runtime PM reference on probe errors Arina Kharlamova via B4 Relay
2026-12-01 19:07 ` [PATCH 6/6] ASoC: codecs: wsa881x: Disable runtime PM on unbind Arina Kharlamova via B4 Relay
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox