Skip to contentSkip to conversation

ASoC: Intel: Fix MCLK leaks in

PATCH Superseded [email protected] 2 participants 17 messages Mar 27 – Apr 9

Subsystems (3)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

cover ASoC: Intel: Fix MCLK leaks in

From: Aravind Anilraj <[email protected]>

In three Intel ASoC board drivers, the EVENT_ON path in platform_clock_control() enables MCLK via clk_prepare_enable() but fails to call clk_disable_unprepare() on subsequent error paths, leaking the clock reference.

Fix this across all three affected drivers.

Aravind Anilraj (3):
ASoC: Intel: bytcr_rt5640: Fix MCLK leak on platform_clock_control
error
ASoC: Intel: bytcr_rt5651: Fix MCLK leak on platform_clock_control
error
ASoC: Intel: cht_bsw_rt5672: Fix MCLK leak in platform_clock_control

 sound/soc/intel/boards/bytcr_rt5640.c   | 1 +
 sound/soc/intel/boards/bytcr_rt5651.c   | 3 ++-
 sound/soc/intel/boards/cht_bsw_rt5672.c | 4 +++-
 3 files changed, 6 insertions(+), 2 deletions(-)
Signature · 1 line
2.47.3
#1 lore raw

PATCH 1/3 ASoC: Intel: bytcr_rt5640: Fix MCLK leak on platform_clock_control error

From: Aravind Anilraj <[email protected]>

If byt_rt5640_prepare_and_enable_pll1() fails, the function returns without calling clk_disable_unprepare() on priv->mclk, which was already enabled earlier in the same code path. Add the missing clk_disable_unprepare() call before returning the error

---
 sound/soc/intel/boards/bytcr_rt5640.c | 1 +
 1 file changed, 1 insertion(+)
sound/soc/intel/boards/bytcr_rt5640.c +1 -0
index 103e0b445603..3ecfba161e56 100644
@@ -304,6 +304,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
 
 	if (ret < 0) {
 		dev_err(card->dev, "can't set codec sysclk: %d\n", ret);
+		clk_disable_unprepare(priv->mclk);
 		return ret;
 	}
 
Signature · 1 line
2.47.3
#2 lore raw

PATCH 2/3 ASoC: Intel: bytcr_rt5651: Fix MCLK leak on platform_clock_control error

In reply to [email protected]

From: Aravind Anilraj <[email protected]>

If byt_rt5651_prepare_and_enable_pll1() fails, the function returns without calling clk_disable_unprepare() on priv->mclk, which was already enabled earlier in the same code path. Add the missing clk_disable_unprepare() call before returning the error.

---
 sound/soc/intel/boards/bytcr_rt5651.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/intel/boards/bytcr_rt5651.c +2 -1
index 68cf463f1d50..2eef9a6dc8f3 100644
@@ -205,7 +205,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
 	if (SND_SOC_DAPM_EVENT_ON(event)) {
 		ret = clk_prepare_enable(priv->mclk);
 		if (ret < 0) {
-			dev_err(card->dev, "could not configure MCLK state");
+			dev_err(card->dev, "could not configure MCLK state\n");
 			return ret;
 		}
 		ret = byt_rt5651_prepare_and_enable_pll1(codec_dai, 48000, 50);
@@ -224,6 +224,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
 
 	if (ret < 0) {
 		dev_err(card->dev, "can't set codec sysclk: %d\n", ret);
+		clk_disable_unprepare(priv->mclk);
 		return ret;
 	}
 
Signature · 1 line
2.47.3
maintainer
#3 lore raw

Re: [PATCH 2/3] ASoC: Intel: bytcr_rt5651: Fix MCLK leak on platform_clock_control error

Quoted 6 lines · On Fri, Mar 27, 2026 at 03:30:01PM -0400, [email protected] wrote:

From: Aravind Anilraj <[email protected]>

If byt_rt5651_prepare_and_enable_pll1() fails, the function returns without calling clk_disable_unprepare() on priv->mclk, which was already enabled earlier in the same code path. Add the missing clk_disable_unprepare() call before returning the error.

The changelog does not mention this...

sound/soc/intel/boards/bytcr_rt5651.c static int platform_clock_control(struct snd_soc_dapm_widget *w, · line 211

Quoted 8 lines
sound/soc/intel/boards/bytcr_rt5651.c +1 -1
 	if (SND_SOC_DAPM_EVENT_ON(event)) {
 		ret = clk_prepare_enable(priv->mclk);
 		if (ret < 0) {
-			dev_err(card->dev, "could not configure MCLK state");
+			dev_err(card->dev, "could not configure MCLK state\n");
 			return ret;
 		}
 		ret = byt_rt5651_prepare_and_enable_pll1(codec_dai, 48000, 50);

...separate change which is unrelated and really should be a separate patch as covered in submitting-patches.rst.

It's a good enough change, ideally we'd log the return code as well.

#4 lore raw

PATCH 3/3 ASoC: Intel: cht_bsw_rt5672: Fix MCLK leak in platform_clock_control

In reply to [email protected]

From: Aravind Anilraj <[email protected]>

If snd_soc_dai_set_pll() or snd_soc_dai_set_sysclk() fail inside the EVENT_ON path, the function returns without calling clk_disable_unprepare() on ctx->mclk, which was already enabled earlier in the same code path. Add the missing clk_disable_unprepare() calls before returning the error.

---
 sound/soc/intel/boards/cht_bsw_rt5672.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/intel/boards/cht_bsw_rt5672.c +3 -1
index 359723f2700e..e5806dc16ff9 100644
@@ -67,7 +67,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
 			ret = clk_prepare_enable(ctx->mclk);
 			if (ret < 0) {
 				dev_err(card->dev,
-					"could not configure MCLK state");
+					"could not configure MCLK state\n");
 				return ret;
 			}
 		}
@@ -77,6 +77,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
 				CHT_PLAT_CLK_3_HZ, 48000 * 512);
 		if (ret < 0) {
 			dev_err(card->dev, "can't set codec pll: %d\n", ret);
+			clk_disable_unprepare(ctx->mclk);
 			return ret;
 		}
 
@@ -85,6 +86,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
 			48000 * 512, SND_SOC_CLOCK_IN);
 		if (ret < 0) {
 			dev_err(card->dev, "can't set codec sysclk: %d\n", ret);
+			clk_disable_unprepare(ctx->mclk);
 			return ret;
 		}
 	} else {
Signature · 1 line
2.47.3
maintainer
#5 lore raw

Re: [PATCH 3/3] ASoC: Intel: cht_bsw_rt5672: Fix MCLK leak in platform_clock_control

sound/soc/intel/boards/cht_bsw_rt5672.c static int platform_clock_control(struct snd_soc_dapm_widget *w, · line 73

Quoted 8 lines · On Fri, Mar 27, 2026 at 03:30:02PM -0400, [email protected] wrote:
sound/soc/intel/boards/cht_bsw_rt5672.c +1 -1
 			ret = clk_prepare_enable(ctx->mclk);
 			if (ret < 0) {
 				dev_err(card->dev,
-					"could not configure MCLK state");
+					"could not configure MCLK state\n");
 				return ret;
 			}
 		}

Same thing here.

#6 lore raw

v2 cover ASoC: Intel: Fix MCLK leaks in

In reply to [email protected]

From: Aravind Anilraj <[email protected]>

In three Intel ASoC board drivers, the EVENT_ON path in platform_clock_control() enables MCLK using clk_prepare_enable(), but error paths fail to call clk_disable_unprepare(), leaking a clock reference.

Fix this by calling a clk_disable_unprepare() on error paths after MCLK has been enabled.

v2: Guard clk_disable_unprepare() with SND_SOC_DAPM_EVENT_ON() to avoid callling it in the EVENT_OFF error path where MCLK was never enabled.

Aravind Anilraj (3):
ASoC: Intel: bytcr_rt5640: Fix MCLK leak on platform_clock_control
error
ASoC: Intel: bytcr_rt5651: Fix MCLK leak on platform_clock_control
error
ASoC: Intel: cht_bsw_rt5672: Fix MCLK leak in platform_clock_control

 sound/soc/intel/boards/bytcr_rt5640.c   | 2 ++
 sound/soc/intel/boards/bytcr_rt5651.c   | 2 +-
 sound/soc/intel/boards/cht_bsw_rt5672.c | 4 +++-
 3 files changed, 6 insertions(+), 2 deletions(-)
Signature · 1 line
2.47.3
#7 lore raw

PATCH v2 1/3 ASoC: Intel: bytcr_rt5640: Fix MCLK leak on platform_clock_control error

From: Aravind Anilraj <[email protected]>

If byt_rt5640_prepare_and_enable_pll1() fails, the function returns without calling clk_disable_unprepare() on priv->mclk, which was already enabled earlier in the same code path. Add the missing clk_disable_unprepare() call before returning the error.

---
 sound/soc/intel/boards/bytcr_rt5640.c | 2 ++
 1 file changed, 2 insertions(+)
sound/soc/intel/boards/bytcr_rt5640.c +2 -0
index 103e0b445603..fce726a9c8c0 100644
@@ -304,6 +304,8 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
 
 	if (ret < 0) {
 		dev_err(card->dev, "can't set codec sysclk: %d\n", ret);
+		if (SND_SOC_DAPM_EVENT_ON(event))
+			clk_disable_unprepare(priv->mclk);
 		return ret;
 	}
 
Signature · 1 line
2.47.3
#8 lore raw

PATCH v2 2/3 ASoC: Intel: bytcr_rt5651: Fix MCLK leak on platform_clock_control error

In reply to [email protected]

From: Aravind Anilraj <[email protected]>

If byt_rt5651_prepare_and_enable_pll1() fails, the function returns without calling clk_disable_unprepare() on priv->mclk, which was already enabled earlier in the same code path. Add the missing clk_disable_unprepare() call before returning the error.

---
 sound/soc/intel/boards/bytcr_rt5651.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/intel/boards/bytcr_rt5651.c +1 -1
index 68cf463f1d50..9f19eb483c69 100644
@@ -205,7 +205,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
 	if (SND_SOC_DAPM_EVENT_ON(event)) {
 		ret = clk_prepare_enable(priv->mclk);
 		if (ret < 0) {
-			dev_err(card->dev, "could not configure MCLK state");
+			dev_err(card->dev, "could not configure MCLK state\n");
 			return ret;
 		}
 		ret = byt_rt5651_prepare_and_enable_pll1(codec_dai, 48000, 50);
Signature · 1 line
2.47.3
#9 lore raw

PATCH v2 3/3 ASoC: Intel: cht_bsw_rt5672: Fix MCLK leak in platform_clock_control

In reply to [email protected]

From: Aravind Anilraj <[email protected]>

If snd_soc_dai_set_pll() or snd_soc_dai_set_sysclk() fail inside the EVENT_ON path, the function returns without calling clk_disable_unprepare() on ctx->mclk, which was already enabled earlier in the same code path. Add the missing clk_disable_unprepare() calls before returning the error.

---
 sound/soc/intel/boards/cht_bsw_rt5672.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/intel/boards/cht_bsw_rt5672.c +3 -1
index 359723f2700e..e5806dc16ff9 100644
@@ -67,7 +67,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
 			ret = clk_prepare_enable(ctx->mclk);
 			if (ret < 0) {
 				dev_err(card->dev,
-					"could not configure MCLK state");
+					"could not configure MCLK state\n");
 				return ret;
 			}
 		}
@@ -77,6 +77,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
 				CHT_PLAT_CLK_3_HZ, 48000 * 512);
 		if (ret < 0) {
 			dev_err(card->dev, "can't set codec pll: %d\n", ret);
+			clk_disable_unprepare(ctx->mclk);
 			return ret;
 		}
 
@@ -85,6 +86,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
 			48000 * 512, SND_SOC_CLOCK_IN);
 		if (ret < 0) {
 			dev_err(card->dev, "can't set codec sysclk: %d\n", ret);
+			clk_disable_unprepare(ctx->mclk);
 			return ret;
 		}
 	} else {
Signature · 1 line
2.47.3
#10 lore raw

v3 cover ASoC: Intel: Fix MCLK leaks in platform_clock_control

In reply to [email protected]

From: Aravind Anilraj <[email protected]>

In three Intel ASoC board drivers, the EVENT_ON path in platform_clock_control() enables MCLK using clk_prepare_enable(), but error paths fail to call clk_disable_unprepare(), leaking a clock reference.

Fix this by calling a clk_disable_unprepare() on error paths after MCLK has been enabled.

v2: Guard clk_disable_unprepare() with SND_SOC_DAPM_EVENT_ON() to avoid callling it in the EVENT_OFF error path where MCLK was never enabled.

v3: Restored missing clk_disable_unprepare() guard in patch 2 that was accidentally dropped during v2 rebase.

Aravind Anilraj (3):
ASoC: Intel: bytcr_rt5640: Fix MCLK leak on platform_clock_control
error
ASoC: Intel: bytcr_rt5651: Fix MCLK leak on platform_clock_control
error
ASoC: Intel: cht_bsw_rt5672: Fix MCLK leak in platform_clock_control

 sound/soc/intel/boards/bytcr_rt5640.c   | 2 ++
 sound/soc/intel/boards/bytcr_rt5651.c   | 4 +++-
 sound/soc/intel/boards/cht_bsw_rt5672.c | 4 +++-
 3 files changed, 8 insertions(+), 2 deletions(-)
Signature · 1 line
2.47.3
#11 lore raw

PATCH v3 1/3 ASoC: Intel: bytcr_rt5640: Fix MCLK leak on platform_clock_control error

From: Aravind Anilraj <[email protected]>

If byt_rt5640_prepare_and_enable_pll1() fails, the function returns without calling clk_disable_unprepare() on priv->mclk, which was already enabled earlier in the same code path. Add the missing clk_disable_unprepare() call before returning the error.

---
 sound/soc/intel/boards/bytcr_rt5640.c | 2 ++
 1 file changed, 2 insertions(+)
sound/soc/intel/boards/bytcr_rt5640.c +2 -0
index 103e0b445603..fce726a9c8c0 100644
@@ -304,6 +304,8 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
 
 	if (ret < 0) {
 		dev_err(card->dev, "can't set codec sysclk: %d\n", ret);
+		if (SND_SOC_DAPM_EVENT_ON(event))
+			clk_disable_unprepare(priv->mclk);
 		return ret;
 	}
 
Signature · 1 line
2.47.3
#12 lore raw

PATCH v3 2/3 ASoC: Intel: bytcr_rt5651: Fix MCLK leak on platform_clock_control error

In reply to [email protected]

From: Aravind Anilraj <[email protected]>

If byt_rt5651_prepare_and_enable_pll1() fails, the function returns without calling clk_disable_unprepare() on priv->mclk, which was already enabled earlier in the same code path. Add the missing clk_disable_unprepare() call before returning the error.

---
 sound/soc/intel/boards/bytcr_rt5651.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/intel/boards/bytcr_rt5651.c +3 -1
index 68cf463f1d50..65944eb4be16 100644
@@ -205,7 +205,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
 	if (SND_SOC_DAPM_EVENT_ON(event)) {
 		ret = clk_prepare_enable(priv->mclk);
 		if (ret < 0) {
-			dev_err(card->dev, "could not configure MCLK state");
+			dev_err(card->dev, "could not configure MCLK state\n");
 			return ret;
 		}
 		ret = byt_rt5651_prepare_and_enable_pll1(codec_dai, 48000, 50);
@@ -224,6 +224,8 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
 
 	if (ret < 0) {
 		dev_err(card->dev, "can't set codec sysclk: %d\n", ret);
+		if (SND_SOC_DAPM_EVENT_ON(event))
+			clk_disable_unprepare(priv->mclk);
 		return ret;
 	}
 
Signature · 1 line
2.47.3
#13 lore raw

PATCH v3 3/3 ASoC: Intel: cht_bsw_rt5672: Fix MCLK leak in platform_clock_control

In reply to [email protected]

From: Aravind Anilraj <[email protected]>

If snd_soc_dai_set_pll() or snd_soc_dai_set_sysclk() fail inside the EVENT_ON path, the function returns without calling clk_disable_unprepare() on ctx->mclk, which was already enabled earlier in the same code path. Add the missing clk_disable_unprepare() calls before returning the error.

---
 sound/soc/intel/boards/cht_bsw_rt5672.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/intel/boards/cht_bsw_rt5672.c +3 -1
index 359723f2700e..e5806dc16ff9 100644
@@ -67,7 +67,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
 			ret = clk_prepare_enable(ctx->mclk);
 			if (ret < 0) {
 				dev_err(card->dev,
-					"could not configure MCLK state");
+					"could not configure MCLK state\n");
 				return ret;
 			}
 		}
@@ -77,6 +77,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
 				CHT_PLAT_CLK_3_HZ, 48000 * 512);
 		if (ret < 0) {
 			dev_err(card->dev, "can't set codec pll: %d\n", ret);
+			clk_disable_unprepare(ctx->mclk);
 			return ret;
 		}
 
@@ -85,6 +86,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
 			48000 * 512, SND_SOC_CLOCK_IN);
 		if (ret < 0) {
 			dev_err(card->dev, "can't set codec sysclk: %d\n", ret);
+			clk_disable_unprepare(ctx->mclk);
 			return ret;
 		}
 	} else {
Signature · 1 line
2.47.3
maintainer
#14 lore raw

Re: [PATCH v3 0/3] ASoC: Intel: Fix MCLK leaks in platform_clock_control

In reply to [email protected]
Quoted 6 lines · On Fri, Mar 27, 2026 at 05:04:05PM -0400, [email protected] wrote:

From: Aravind Anilraj <[email protected]>

In three Intel ASoC board drivers, the EVENT_ON path in platform_clock_control() enables MCLK using clk_prepare_enable(), but error paths fail to call clk_disable_unprepare(), leaking a clock reference.

Please don't send new patches in reply to old patches or serieses, this makes it harder for both people and tools to understand what is going on - it can bury things in mailboxes and make it difficult to keep track of what current patches are, both for the new patches and the old ones.

Please don't ignore review comments, people are generally making them for a reason and are likely to have the same concerns if issues remain unaddressed. Having to repeat the same comments can get repetitive and make people question the value of time spent reviewing. If you disagree with the review comments that's fine but you need to reply and discuss your concerns so that the reviewer can understand your decisions.

author
#15 lore raw

Re: [PATCH v3 0/3] ASoC: Intel: Fix MCLK leaks in platform_clock_control

Hi Mark,

Thanks for the feedback.

Apologies for the confusion — I sent multiple revisions in quick succession and incorrectly threaded the newer version as a reply to the earlier series. I understand this makes tracking harder.

In v4, I have:
Split unrelated changes into a separate patch Added return codes to dev_err() messages as suggested

I will send future revisions as a new thread instead of replying to older series.

Thanks for the review.

Regards,
Aravind

Quoted 20 lines · Mark Brown
Quoted 6 lines · On Fri, Mar 27, 2026 at 05:04:05PM -0400, [email protected] wrote:

From: Aravind Anilraj <[email protected]>

In three Intel ASoC board drivers, the EVENT_ON path in platform_clock_control() enables MCLK using clk_prepare_enable(), but error paths fail to call clk_disable_unprepare(), leaking a clock reference.

Please don't send new patches in reply to old patches or serieses, this makes it harder for both people and tools to understand what is going on - it can bury things in mailboxes and make it difficult to keep track of what current patches are, both for the new patches and the old ones.

Please don't ignore review comments, people are generally making them for a reason and are likely to have the same concerns if issues remain unaddressed. Having to repeat the same comments can get repetitive and make people question the value of time spent reviewing. If you disagree with the review comments that's fine but you need to reply and discuss your concerns so that the reviewer can understand your decisions.

maintainer
#16 lore raw
In reply to [email protected]
Quoted 8 lines · On Fri, 27 Mar 2026 15:29:59 -0400, [email protected] wrote:

In three Intel ASoC board drivers, the EVENT_ON path in platform_clock_control() enables MCLK via clk_prepare_enable() but fails to call clk_disable_unprepare() on subsequent error paths, leaking the clock reference.

Fix this across all three affected drivers.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/3] ASoC: Intel: bytcr_rt5640: Fix MCLK leak on platform_clock_control error

      https://git.kernel.org/broonie/misc/c/a02496a29463
[2/3] ASoC: Intel: bytcr_rt5651: Fix MCLK leak on platform_clock_control error
      https://git.kernel.org/broonie/misc/c/b022e5c142ef

[3/3] ASoC: Intel: cht_bsw_rt5672: Fix MCLK leak in platform_clock_control
(no commit info)

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark