Linux Sound subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sreeraj S Kurup" <sreekuttan2156239@gmail.com>
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH] ALSA: hda: cix-ipbloq: Fix runtime PM handling on probe failure
Date: Wed, 02 Dec 2026 09:56:23 +0000	[thread overview]
Message-ID: <sashiko-outbox-245369@kernel.org> (raw)
In-Reply-To: <20261202094026.4432-1-sreekuttan2156239@gmail.com>

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

      reply	other threads:[~2026-12-02  9:56 UTC|newest]

Thread overview: 2+ 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 [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-245369@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox