From: sashiko-bot@kernel.org
To: "Sreeraj S Kurup" <sreekuttan2156239@gmail.com>
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH v3] ALSA: hda: cix-ipbloq: Fix runtime PM handling on probe failure
Date: Wed, 02 Dec 2026 10:59:48 +0000 [thread overview]
Message-ID: <sashiko-outbox-245543@kernel.org> (raw)
In-Reply-To: <20261202103518.4945-1-sreekuttan2156239@gmail.com>
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
prev parent reply other threads:[~2026-12-02 10:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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
2026-12-02 10:59 ` sashiko-bot [this message]
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=sashiko-outbox-245543@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sreekuttan2156239@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.