Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH] ASoC: mxs-saif: unregister the mclk if adding the provider fails
@ 2026-11-04  2:40 Wentao Liang
  2026-11-04  2:49 ` sashiko-bot
  2026-11-04 18:20 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Wentao Liang @ 2026-11-04  2:40 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Frank Li, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam
  Cc: linux-sound, imx, linux-arm-kernel

clk_register_divider() registers the mclk, while of_clk_add_provider() only
stores it as the provider data. If of_clk_add_provider() fails, the clock
stays registered but no provider refers to it, and the driver has no remove
callback to release it, so the clock is leaked.

Unregister the clock on this error path before returning.

Fixes: 7c9e6150f2e7 ("ASoC: mxs: register saif mclk to clock framework")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 sound/soc/mxs/mxs-saif.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c
index e46896ac9669..aaf62f081b32 100644
--- a/sound/soc/mxs/mxs-saif.c
+++ b/sound/soc/mxs/mxs-saif.c
@@ -783,8 +783,10 @@ static int mxs_saif_mclk_init(struct platform_device *pdev)
 	}
 
 	ret = of_clk_add_provider(np, of_clk_src_simple_get, clk);
-	if (ret)
+	if (ret) {
+		clk_unregister(clk);
 		return ret;
+	}
 
 	return 0;
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-04 18:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-04  2:40 [PATCH] ASoC: mxs-saif: unregister the mclk if adding the provider fails Wentao Liang
2026-11-04  2:49 ` sashiko-bot
2026-11-04 18:20 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox