[PATCH 4/4] clk: mediatek: mt8516: Unregister apmixedsys clocks on unbind
From: Guangshuo Li
Date: Thu Nov 26 2026 - 03:26:25 EST
The apmixedsys driver leaves the OF provider and clocks registered
on unbind. The clock table is device-managed, so the provider can
retain a pointer to released storage.
Remove the provider and unregister the PLLs during removal.
This issue was found by our static analysis tool under development.
Fixes: f419069ad864 ("clk: mediatek: mt8516: Move apmixedsys clock driver to its own file")
Signed-off-by: Guangshuo Li <liguangshuo@xxxxxxxxxxxxxxx>
---
drivers/clk/mediatek/clk-mt8516-apmixedsys.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/clk/mediatek/clk-mt8516-apmixedsys.c b/drivers/clk/mediatek/clk-mt8516-apmixedsys.c
index 2a6206cae2f0..abb2a626628c 100644
--- a/drivers/clk/mediatek/clk-mt8516-apmixedsys.c
+++ b/drivers/clk/mediatek/clk-mt8516-apmixedsys.c
@@ -95,6 +95,8 @@ static int clk_mt8516_apmixed_probe(struct platform_device *pdev)
if (ret)
goto unregister_plls;
+ platform_set_drvdata(pdev, clk_data);
+
return 0;
unregister_plls:
@@ -103,6 +105,14 @@ static int clk_mt8516_apmixed_probe(struct platform_device *pdev)
return ret;
}
+static void clk_mt8516_apmixed_remove(struct platform_device *pdev)
+{
+ struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
+
+ of_clk_del_provider(pdev->dev.of_node);
+ mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data);
+}
+
static const struct of_device_id of_match_clk_mt8516_apmixed[] = {
{ .compatible = "mediatek,mt8516-apmixedsys" },
{ /* sentinel */ }
@@ -111,6 +121,7 @@ MODULE_DEVICE_TABLE(of, of_match_clk_mt8516_apmixed);
static struct platform_driver clk_mt8516_apmixed_drv = {
.probe = clk_mt8516_apmixed_probe,
+ .remove = clk_mt8516_apmixed_remove,
.driver = {
.name = "clk-mt8516-apmixed",
.of_match_table = of_match_clk_mt8516_apmixed,
--
2.43.0