ASoC: Intel: Fix MCLK leaks and clean up error
Subsystems (3)
v6 cover ASoC: Intel: Fix MCLK leaks and clean up error
From: Aravind Anilraj <[email protected]>
This series fixes MCLK resource leaks in the platform_clock_control() implementations for bytcr_rt5640, bytcr_rt5651, and cht_bsw_rt5672.
In the SND_SOC_DAPM_EVENT_ON() path, clk_prepare_enable() is called to enable MCLK, but subsequent failures in codec clock configuration (eg:*_prepare_and_enable_pll1() or snd_soc_dai_set_sysclk()) return without disabling the clock, leaking a reference.
Patches 1-3 fix this by adding the missing clk_disable_unprepare() calls in the relevant error paths, ensuring proper symmetry between enable and disable operations within the EVENT_ON scope.
Patch 4 moves unrelated logging changes into a separate patch and standardizes error messages.
Changes in v6:
Place cleanup logic within SND_SOC_DAPM_EVENT_ON() scope Avoid redundant condition checks in error paths Split logging changes into a separate patch Address review feedback from Mark Brown and Cezary Rojewski
Aravind Anilraj (4):
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 on platform_clock_control
error
ASoC: Intel: Standardize MCLK error logs across RT boards
sound/soc/intel/boards/bytcr_rt5640.c | 4 +++- sound/soc/intel/boards/bytcr_rt5651.c | 4 +++- sound/soc/intel/boards/cht_bsw_rt5672.c | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-)
Signature · 1 line
2.47.3
PATCH v6 1/4 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 cleanup call to prevent the clock from leaking.
--- sound/soc/intel/boards/bytcr_rt5640.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/intel/boards/bytcr_rt5640.c +2 -0
@@ -289,6 +289,8 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,return ret; } ret =byt_rt5640_prepare_and_enable_pll1 (codec_dai,48000 ); +if (ret <0 ) +clk_disable_unprepare (priv->mclk); }else {/* * Set codec clock source to internal clock before
Signature · 1 line
2.47.3
PATCH v6 2/4 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 cleanup call to prevent the clock from leaking.
--- sound/soc/intel/boards/bytcr_rt5651.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/intel/boards/bytcr_rt5651.c +2 -0
@@ -209,6 +209,8 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,return ret; } ret =byt_rt5651_prepare_and_enable_pll1 (codec_dai,48000 ,50 ); +if (ret <0 ) +clk_disable_unprepare (priv->mclk); }else {/* * Set codec clock source to internal clock before
Signature · 1 line
2.47.3
PATCH v6 3/4 ASoC: Intel: cht_bsw_rt5672: Fix MCLK leak on platform_clock_control error
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, 4 insertions(+)
sound/soc/intel/boards/cht_bsw_rt5672.c +4 -0
@@ -77,6 +77,8 @@ 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); +if (ctx->mclk) +clk_disable_unprepare (ctx->mclk);return ret; }
@@ -85,6 +87,8 @@ 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); +if (ctx->mclk) +clk_disable_unprepare (ctx->mclk);return ret; } }else {
Signature · 1 line
2.47.3
PATCH v6 4/4 ASoC: Intel: Standardize MCLK error logs across RT boards
In reply to [email protected]From: Aravind Anilraj <[email protected]>
Standardize the error logging in platform_clock_control() by adding missing newline characters to dev_err() strings. Additionally, include the return code in the error messages to assist with debugging.
--- sound/soc/intel/boards/bytcr_rt5640.c | 2 +- sound/soc/intel/boards/bytcr_rt5651.c | 2 +- sound/soc/intel/boards/cht_bsw_rt5672.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
sound/soc/intel/boards/bytcr_rt5640.c +1 -1
@@ -285,7 +285,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\n" ); +dev_err (card->dev,"could not configure MCLK state: %d\n" , ret);return ret; } ret =byt_rt5640_prepare_and_enable_pll1 (codec_dai,48000 );
sound/soc/intel/boards/bytcr_rt5651.c +1 -1
@@ -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: %d\n" , ret);return ret; } ret =byt_rt5651_prepare_and_enable_pll1 (codec_dai,48000 ,50 );
sound/soc/intel/boards/cht_bsw_rt5672.c +1 -1
@@ -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: %d\n" , ret);return ret; } }
Signature · 1 line
2.47.3
Quoted 32 lines · On 2026-04-02 12:05 AM, [email protected] wrote:
From: Aravind Anilraj <[email protected]>
This series fixes MCLK resource leaks in the
platform_clock_control()implementations forbytcr_rt5640,bytcr_rt5651, andcht_bsw_rt5672.In the
SND_SOC_DAPM_EVENT_ON()path,clk_prepare_enable()is called to enable MCLK, but subsequent failures in codec clock configuration (eg:*_prepare_and_enable_pll1()orsnd_soc_dai_set_sysclk()) return without disabling the clock, leaking a reference.Patches 1-3 fix this by adding the missing
clk_disable_unprepare()calls in the relevant error paths, ensuring proper symmetry between enable and disable operations within theEVENT_ONscope.Patch 4 moves unrelated logging changes into a separate patch and standardizes error messages.
Changes in v6:
Place cleanup logic withinSND_SOC_DAPM_EVENT_ON()scope Avoid redundant condition checks in error paths Split logging changes into a separate patch Address review feedback from Mark Brown and Cezary RojewskiAravind Anilraj (4):
ASoC: Intel:bytcr_rt5640: Fix MCLK leak onplatform_clock_control
error
ASoC: Intel:bytcr_rt5651: Fix MCLK leak onplatform_clock_control
error
ASoC: Intel:cht_bsw_rt5672: Fix MCLK leak onplatform_clock_control
error
ASoC: Intel: Standardize MCLK error logs across RT boards
Quoted 5 lines
sound/soc/intel/boards/bytcr_rt5640.c | 4 +++- sound/soc/intel/boards/bytcr_rt5651.c | 4 +++- sound/soc/intel/boards/cht_bsw_rt5672.c | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-)
Thank you for the update. For the series:
Mark Brown
maintainerQuoted 8 lines · On Wed, 01 Apr 2026 18:05:03 -0400, [email protected] wrote:
ASoC: Intel: Fix MCLK leaks and clean up error
From: Aravind Anilraj <[email protected]>
This series fixes MCLK resource leaks in the
platform_clock_control()implementations forbytcr_rt5640,bytcr_rt5651, andcht_bsw_rt5672.[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.1
Thanks!
[1/4] ASoC: Intel: bytcr_rt5640: Fix MCLK leak on platform_clock_control error
https://git.kernel.org/broonie/sound/c/a02496a29463 [2/4] ASoC: Intel: bytcr_rt5651: Fix MCLK leak on platform_clock_control error https://git.kernel.org/broonie/sound/c/b022e5c142ef [3/4] ASoC: Intel: cht_bsw_rt5672: Fix MCLK leak on platform_clock_control error https://git.kernel.org/broonie/sound/c/dced5a373a96 [4/4] ASoC: Intel: Standardize MCLK error logs across RT boards https://git.kernel.org/broonie/sound/c/85c38c2fa17d
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
Thanks Mark, appreciate it.
Quoted 45 lines · Mark Brown
Quoted 8 lines · On Wed, 01 Apr 2026 18:05:03 -0400, [email protected] wrote:
ASoC: Intel: Fix MCLK leaks and clean up error
From: Aravind Anilraj <[email protected]>
This series fixes MCLK resource leaks in the
platform_clock_control()implementations forbytcr_rt5640,bytcr_rt5651, andcht_bsw_rt5672.[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.1
Thanks!
[1/4] ASoC: Intel:
bytcr_rt5640: Fix MCLK leak onplatform_clock_controlerrorhttps://git.kernel.org/broonie/sound/c/a02496a29463 [2/4] ASoC: Intel: bytcr_rt5651: Fix MCLK leak on platform_clock_control error https://git.kernel.org/broonie/sound/c/b022e5c142ef [3/4] ASoC: Intel: cht_bsw_rt5672: Fix MCLK leak on platform_clock_control error https://git.kernel.org/broonie/sound/c/dced5a373a96 [4/4] ASoC: Intel: Standardize MCLK error logs across RT boards https://git.kernel.org/broonie/sound/c/85c38c2fa17dAll 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