* Re: [PATCH] ALSA: hda: cix-ipbloq: Fix runtime PM handling on probe failure
2026-12-02 9:40 [PATCH] ALSA: hda: cix-ipbloq: Fix runtime PM handling on probe failure Sreeraj S Kurup
@ 2026-12-02 9:56 ` sashiko-bot
2026-12-02 10:23 ` [PATCH v2] " Sreeraj S Kurup
2026-12-02 10:35 ` [PATCH v3] " Sreeraj S Kurup
2 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-12-02 9:56 UTC (permalink / raw)
To: Sreeraj S Kurup; +Cc: linux-sound
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] ALSA: hda: cix-ipbloq: unclocked MMIO or clk leak in
cix_ipbloq_hda_probe()
- [Low] ALSA: hda: cix-ipbloq: unused out_free_device label in
cix_ipbloq_hda_probe()
- [Low] ALSA: hda: cix-ipbloq: missing Fixes trailer in commit message
--
commit 3f3419aa56e19e9c5ac17d7415a0c34a83809b1f
Author: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
> ALSA: hda: cix-ipbloq: Fix runtime PM handling on probe failure
>
> The driver enables runtime PM before calling
> pm_runtime_resume_and_get().
>
> If cix_ipbloq_hda_init() or cix_ipbloq_hda_probe_codec()
> fails, the runtime PM usage reference is not released.
>
> Release the reference on these failure paths and disable
> runtime PM before freeing the ALSA device and card.
>
> Also disable runtime PM if pm_runtime_resume_and_get()
> fails, as runtime PM was already enabled.
>
> Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
[Severity: Low]
This fixes the runtime PM cleanup on the probe error paths. Should the
commit message include:
Fixes: d91e9bd10125 ("ALSA: hda: add CIX IPBLOQ HDA controller support")
> diff --git a/sound/hda/controllers/cix-ipbloq.c b/sound/hda/controllers/cix-ipbloq.c
> index c07098fc13403..1344a5b9760a1 100644
> --- a/sound/hda/controllers/cix-ipbloq.c
> +++ b/sound/hda/controllers/cix-ipbloq.c
> @@ -284,21 +284,25 @@ static int cix_ipbloq_hda_probe(struct platform_device *pdev)
> err = pm_runtime_resume_and_get(hda->dev);
> if (err < 0) {
> dev_err(hda->dev, "runtime resume and get failed, err = %d\n", err);
> - goto out_free_device;
> + goto out_pm_disable;
> }
>
> err = cix_ipbloq_hda_init(hda, chip, pdev);
> if (err < 0)
> - goto out_free_device;
> + goto out_pm_put;
>
> err = cix_ipbloq_hda_probe_codec(hda);
> if (err < 0)
> - goto out_free_device;
> + goto out_pm_put;
>
> pm_runtime_put(hda->dev);
>
> return 0;
>
> +out_pm_put:
> + pm_runtime_put_sync(hda->dev);
> +out_pm_disable:
> + pm_runtime_disable(hda->dev);
[Severity: High]
Does suspending runtime PM before snd_device_free() and snd_card_free()
cause unclocked MMIO accesses in cix_ipbloq_hda_dev_free(), or leak the
enabled controller clocks if child codec devices were already created?
In cix_ipbloq_hda_init(), azx_init_chip() sets azx_bus(chip)->chip_init to
true, while chip->running stays 0 until the end of
cix_ipbloq_hda_probe_codec(). If probe fails after azx_init_chip() and
before codec child devices exist (for example, when !bus->codec_mask),
pm_runtime_put_sync() runs cix_ipbloq_hda_runtime_suspend(), which skips
azx_stop_chip() because chip->running is 0 and disables hda->clocks:
sound/hda/controllers/cix-ipbloq.c:cix_ipbloq_hda_runtime_suspend() {
if (chip && chip->running) {
azx_stop_chip(chip);
azx_enter_link_reset(chip);
}
clk_bulk_disable_unprepare(hda->nclocks, hda->clocks);
}
When snd_device_free(card, chip) then calls cix_ipbloq_hda_dev_free(),
azx_bus(chip)->chip_init is still true, so azx_stop_all_streams() and
azx_stop_chip() read and write HDA controller registers while the clocks
are disabled.
Conversely, if cix_ipbloq_hda_probe_codec() fails in azx_codec_configure()
or snd_hda_card_register() after azx_probe_codecs() has created active
child codec devices, hda->dev->power.child_count is non-zero until
snd_card_free() releases the codecs via snd_hdac_device_exit().
pm_runtime_put_sync() then fails with -EBUSY, and pm_runtime_disable()
prevents cix_ipbloq_hda_runtime_suspend() from running, leaking the
prepared and enabled ipg and per clocks.
Freeing the device and card before running pm_runtime_put_sync() and
pm_runtime_disable() (as cix_ipbloq_hda_remove() does) would stop the chip
while clocked and release child codecs before suspending.
> out_free_device:
> snd_device_free(card, chip);
[Severity: Low]
With all three goto out_free_device statements replaced, does the
out_free_device label trigger an unused-label compiler warning?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202094026.4432-1-sreekuttan2156239@gmail.com?part=1
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v2] ALSA: hda: cix-ipbloq: Fix runtime PM handling on probe failure
2026-12-02 9:40 [PATCH] ALSA: hda: cix-ipbloq: Fix runtime PM handling on probe failure Sreeraj S Kurup
2026-12-02 9:56 ` sashiko-bot
@ 2026-12-02 10:23 ` Sreeraj S Kurup
2026-12-02 10:35 ` [PATCH v3] " Sreeraj S Kurup
2 siblings, 0 replies; 5+ messages in thread
From: Sreeraj S Kurup @ 2026-12-02 10:23 UTC (permalink / raw)
To: sreekuttan2156239, cix-kernel-upstream, fugang.duan, gary.yang,
perex, tiwai
Cc: linux-arm-kernel, linux-kernel, linux-sound
The driver enables runtime PM before calling
pm_runtime_resume_and_get().
If cix_ipbloq_hda_init() or cix_ipbloq_hda_probe_codec()
fails, the runtime PM usage reference must be released.
However, calling pm_runtime_put_sync() before freeing the
ALSA device can trigger runtime suspend and disable the
controller clocks. The ALSA device cleanup may then access
controller registers while the clocks are disabled.
Disable runtime PM first and keep the controller clocks
enabled while freeing the ALSA device and card. Then balance
the runtime PM reference without triggering runtime suspend
and disable the clocks explicitly.
Also disable runtime PM if pm_runtime_resume_and_get()
fails.
Fixes: d91e9bd10125 ("ALSA: hda: add CIX IPBLOQ HDA controller support")
Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
---
sound/hda/controllers/cix-ipbloq.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/sound/hda/controllers/cix-ipbloq.c b/sound/hda/controllers/cix-ipbloq.c
index f73d6216bce3..10ae8729c312 100644
--- a/sound/hda/controllers/cix-ipbloq.c
+++ b/sound/hda/controllers/cix-ipbloq.c
@@ -237,6 +237,7 @@ static int cix_ipbloq_hda_probe(struct platform_device *pdev)
struct cix_ipbloq_hda *hda;
struct snd_card *card;
struct azx *chip;
+ bool pm_ref = false;
int err;
hda = devm_kzalloc_obj(&pdev->dev, *hda);
@@ -284,21 +285,37 @@ static int cix_ipbloq_hda_probe(struct platform_device *pdev)
err = pm_runtime_resume_and_get(hda->dev);
if (err < 0) {
dev_err(hda->dev, "runtime resume and get failed, err = %d\n", err);
- goto out_free_device;
+ goto out_pm_disable;
}
+ pm_ref = true;
+
err = cix_ipbloq_hda_init(hda, chip, pdev);
if (err < 0)
- goto out_free_device;
+ goto out_pm_cleanup;
err = cix_ipbloq_hda_probe_codec(hda);
if (err < 0)
- goto out_free_device;
+ goto out_pm_cleanup;
pm_runtime_put(hda->dev);
return 0;
+out_pm_cleanup:
+ pm_runtime_disable(hda->dev);
+ snd_device_free(card, chip);
+ snd_card_free(card);
+ if (pm_ref) {
+ pm_runtime_put_noidle(hda->dev);
+ clk_bulk_disable_unprepare(hda->nclocks, hda->clocks);
+ }
+ return err;
+
+out_pm_disable:
+ pm_runtime_disable(hda->dev);
+ goto out_free_device;
+
out_free_device:
snd_device_free(card, chip);
out_free_card:
--
2.55.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v3] ALSA: hda: cix-ipbloq: Fix runtime PM handling on probe failure
2026-12-02 9:40 [PATCH] ALSA: hda: cix-ipbloq: Fix runtime PM handling on probe failure Sreeraj S Kurup
2026-12-02 9:56 ` sashiko-bot
2026-12-02 10:23 ` [PATCH v2] " Sreeraj S Kurup
@ 2026-12-02 10:35 ` Sreeraj S Kurup
2026-12-02 10:59 ` sashiko-bot
2 siblings, 1 reply; 5+ messages in thread
From: Sreeraj S Kurup @ 2026-12-02 10:35 UTC (permalink / raw)
To: sreekuttan2156239, cix-kernel-upstream, fugang.duan, gary.yang,
perex, tiwai
Cc: linux-arm-kernel, linux-kernel, linux-sound
The driver enables runtime PM before calling
pm_runtime_resume_and_get().
If cix_ipbloq_hda_init() or cix_ipbloq_hda_probe_codec()
fails, the runtime PM usage reference must be released.
However, calling pm_runtime_put_sync() before freeing the
ALSA device can trigger runtime suspend and disable the
controller clocks. The ALSA device cleanup may then access
controller registers while the clocks are disabled.
Disable runtime PM first and keep the controller clocks
enabled while freeing the ALSA device and card. Then balance
the runtime PM reference without triggering runtime suspend
and disable the clocks explicitly.
Also disable runtime PM if pm_runtime_resume_and_get()
fails.
Fixes: d91e9bd10125 ("ALSA: hda: add CIX IPBLOQ HDA controller support")
Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
---
v3:
- Add the missing changelog for v2.
v2:
- Fix runtime PM cleanup ordering to avoid unclocked MMIO
accesses during ALSA device cleanup.
- Balance the runtime PM reference using pm_runtime_put_noidle()
after freeing the ALSA device and card.
- Keep controller clocks enabled during ALSA cleanup and
disable them afterward.
- Handle runtime PM cleanup when pm_runtime_resume_and_get()
fails.
sound/hda/controllers/cix-ipbloq.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/sound/hda/controllers/cix-ipbloq.c b/sound/hda/controllers/cix-ipbloq.c
index f73d6216bce3..10ae8729c312 100644
--- a/sound/hda/controllers/cix-ipbloq.c
+++ b/sound/hda/controllers/cix-ipbloq.c
@@ -237,6 +237,7 @@ static int cix_ipbloq_hda_probe(struct platform_device *pdev)
struct cix_ipbloq_hda *hda;
struct snd_card *card;
struct azx *chip;
+ bool pm_ref = false;
int err;
hda = devm_kzalloc_obj(&pdev->dev, *hda);
@@ -284,21 +285,37 @@ static int cix_ipbloq_hda_probe(struct platform_device *pdev)
err = pm_runtime_resume_and_get(hda->dev);
if (err < 0) {
dev_err(hda->dev, "runtime resume and get failed, err = %d\n", err);
- goto out_free_device;
+ goto out_pm_disable;
}
+ pm_ref = true;
+
err = cix_ipbloq_hda_init(hda, chip, pdev);
if (err < 0)
- goto out_free_device;
+ goto out_pm_cleanup;
err = cix_ipbloq_hda_probe_codec(hda);
if (err < 0)
- goto out_free_device;
+ goto out_pm_cleanup;
pm_runtime_put(hda->dev);
return 0;
+out_pm_cleanup:
+ pm_runtime_disable(hda->dev);
+ snd_device_free(card, chip);
+ snd_card_free(card);
+ if (pm_ref) {
+ pm_runtime_put_noidle(hda->dev);
+ clk_bulk_disable_unprepare(hda->nclocks, hda->clocks);
+ }
+ return err;
+
+out_pm_disable:
+ pm_runtime_disable(hda->dev);
+ goto out_free_device;
+
out_free_device:
snd_device_free(card, chip);
out_free_card:
--
2.55.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v3] ALSA: hda: cix-ipbloq: Fix runtime PM handling on probe failure
2026-12-02 10:35 ` [PATCH v3] " Sreeraj S Kurup
@ 2026-12-02 10:59 ` sashiko-bot
0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-12-02 10:59 UTC (permalink / raw)
To: Sreeraj S Kurup; +Cc: linux-sound
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] ALSA: hda: cix-ipbloq: premature snd_device_free() in
cix_ipbloq_hda_probe()
- [Medium] ALSA: hda: cix-ipbloq: clock and runtime PM imbalance in
cix_ipbloq_hda_probe()
--
commit e24cdb391cdea38e58578070cee3d1e3249dcceb
Author: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
ALSA: hda: cix-ipbloq: Fix runtime PM handling on probe failure
This commit updates the error paths in cix_ipbloq_hda_probe() to disable
runtime PM, release the runtime PM reference, and disable controller
clocks after freeing the ALSA device and card.
> diff --git a/sound/hda/controllers/cix-ipbloq.c b/sound/hda/controllers/cix-ipbloq.c
> index c07098fc13403..2b7979f42a9c9 100644
> --- a/sound/hda/controllers/cix-ipbloq.c
> +++ b/sound/hda/controllers/cix-ipbloq.c
> @@ -237,6 +237,7 @@ static int cix_ipbloq_hda_probe(struct platform_device *pdev)
> struct cix_ipbloq_hda *hda;
> struct snd_card *card;
> struct azx *chip;
> + bool pm_ref = false;
> int err;
>
> hda = devm_kzalloc_obj(&pdev->dev, *hda);
> @@ -284,21 +285,37 @@ static int cix_ipbloq_hda_probe(struct platform_device *pdev)
> err = pm_runtime_resume_and_get(hda->dev);
> if (err < 0) {
> dev_err(hda->dev, "runtime resume and get failed, err = %d\n", err);
> - goto out_free_device;
> + goto out_pm_disable;
> }
>
> + pm_ref = true;
> +
> err = cix_ipbloq_hda_init(hda, chip, pdev);
> if (err < 0)
> - goto out_free_device;
> + goto out_pm_cleanup;
>
> err = cix_ipbloq_hda_probe_codec(hda);
> if (err < 0)
> - goto out_free_device;
> + goto out_pm_cleanup;
>
> pm_runtime_put(hda->dev);
>
> return 0;
>
> +out_pm_cleanup:
> + pm_runtime_disable(hda->dev);
> + snd_device_free(card, chip);
> + snd_card_free(card);
[Severity: Medium]
Does calling snd_device_free(card, chip) before snd_card_free(card) tear
down the low-level controller before its codec devices?
If cix_ipbloq_hda_probe_codec() fails in azx_codec_configure() or
snd_hda_card_register() after azx_probe_codecs() has created codec
devices, snd_device_free(card, chip) runs cix_ipbloq_hda_dev_free() first.
That frees the CORB/RIRB DMA buffer (bus->rb.area) and calls
snd_hdac_bus_exit() while codecs are still on bus->codec_list, triggering
WARN_ON(!list_empty(&bus->codec_list)) and causing a use-after-free on
bus->corb.buf if a bound codec driver sends HDA verbs when snd_card_free()
unregisters the codecs afterward.
snd_card_free(card) already frees all devices on the card in order (codec
and PCM devices first, SNDRV_DEV_LOWLEVEL last), so snd_device_free(card,
chip) can be dropped before snd_card_free(card).
> + if (pm_ref) {
> + pm_runtime_put_noidle(hda->dev);
> + clk_bulk_disable_unprepare(hda->nclocks, hda->clocks);
> + }
[Severity: Medium]
Can clk_bulk_disable_unprepare() underflow the clock enable and prepare
counts when CONFIG_PM is disabled?
SND_HDA_CIX_IPBLOQ does not depend on CONFIG_PM, and the clocks are only
prepared and enabled in cix_ipbloq_hda_runtime_resume(). Under
!CONFIG_PM, pm_runtime_resume_and_get() returns 0 without running the
callback, so calling clk_bulk_disable_unprepare() here triggers WARN() in
clk_core_disable() and clk_core_unprepare().
When CONFIG_PM is enabled, disabling runtime PM before dropping the
reference and manually disabling the clocks also bypasses runtime suspend
and any attached PM domain callback, and pm_ref is always true at
out_pm_cleanup. Calling pm_runtime_put_sync() and pm_runtime_disable()
after snd_card_free(card) would let runtime PM suspend the device cleanly
after ALSA teardown.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202103518.4945-1-sreekuttan2156239@gmail.com?part=1
^ permalink raw reply [flat|nested] 5+ messages in thread