[PATCH] ASoC: mxs-saif: unregister the mclk if adding the provider fails
Wentao Liang
vulab at iscas.ac.cn
Tue Nov 3 18:40:48 PST 2026
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 at vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab at 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
More information about the linux-arm-kernel
mailing list