All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tang Bin" <tangbin@cmss.chinamobile.com>
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH] ASoC: cs42l43: leak MCLK when PLL enable fails on PRE_PMU
Date: Wed, 04 Nov 2026 08:12:09 +0000	[thread overview]
Message-ID: <sashiko-outbox-196862@kernel.org> (raw)
In-Reply-To: <20261104080257.1144-1-tangbin@cmss.chinamobile.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] ASoC: cs42l43: double clk_disable_unprepare() in cs42l43_pll_ev()
--

commit 22be724b77049d9bdd49902edcd96899ee4749da
Author: Tang Bin <tangbin@cmss.chinamobile.com>

ASoC: cs42l43: leak MCLK when PLL enable fails on PRE_PMU

This commit disables and unprepares MCLK in cs42l43_pll_ev() if
cs42l43_enable_pll() fails during SND_SOC_DAPM_PRE_PMU.

> diff --git a/sound/soc/codecs/cs42l43.c b/sound/soc/codecs/cs42l43.c
> index b6238f89c789c..6f308ea227fb6 100644
> --- a/sound/soc/codecs/cs42l43.c
> +++ b/sound/soc/codecs/cs42l43.c
> @@ -1625,6 +1625,8 @@ static int cs42l43_pll_ev(struct snd_soc_dapm_widget *w,
>  		}
>  
>  		ret = cs42l43_enable_pll(priv);
> +		if (ret && priv->refclk_src == CS42L43_SYSCLK_MCLK)
> +			clk_disable_unprepare(priv->mclk);

[Severity: High]
Does this cause a double clk_disable_unprepare(priv->mclk) when the widget
later powers down?

In sound/soc/soc-dapm.c, dapm_seq_run_coalesced() sets w->power before
running SND_SOC_DAPM_PRE_PMU:

sound/soc/soc-dapm.c:dapm_seq_run_coalesced() {
	list_for_each_entry(w, pending, power_list) {
		WARN_ON(reg != w->reg || dapm != w->dapm);
		w->power = w->new_power;
		...
		/* Check for events */
		dapm_seq_check_event(card, w, SND_SOC_DAPM_PRE_PMU);

And dapm_seq_check_event() only logs an error when w->event() returns a
negative value, without rolling back w->power:

sound/soc/soc-dapm.c:dapm_seq_check_event() {
		ret = w->event(w, NULL, event);
		trace_snd_soc_dapm_widget_event_done(w, event);
		if (ret < 0)
			dev_err(dev, "ASoC: %s: %s event failed: %d\n",
			       ev_name, w->name, ret);

Because w->power remains 1 even when cs42l43_enable_pll() fails, DAPM will
still run the SND_SOC_DAPM_POST_PMD event when the audio path powers down:

sound/soc/codecs/cs42l43.c:cs42l43_pll_ev() {
	case SND_SOC_DAPM_POST_PMD:
		ret = cs42l43_disable_pll(priv);

		if (priv->refclk_src == CS42L43_SYSCLK_MCLK)
			clk_disable_unprepare(priv->mclk);
		break;

Wouldn't disabling priv->mclk in the SND_SOC_DAPM_PRE_PMU error path cause
SND_SOC_DAPM_POST_PMD to call clk_disable_unprepare(priv->mclk) a second
time and underflow the clock enable and prepare reference counts?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261104080257.1144-1-tangbin@cmss.chinamobile.com?part=1

  reply	other threads:[~2026-11-04  8:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04  8:02 [PATCH] ASoC: cs42l43: leak MCLK when PLL enable fails on PRE_PMU Tang Bin
2026-11-04  8:12 ` sashiko-bot [this message]
2026-11-04 11:04 ` Charles Keepax
2026-11-06  1:01   ` Tang Bin

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-196862@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tangbin@cmss.chinamobile.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.