[PATCH 06/32] clk: mediatek: mt8192: fix memory leak on module removal

From: Akari Tsuyukusa

Date: Mon Aug 03 2026 - 11:54:09 EST


clk_mt8192_apmixed_probe() in clk-mt8192-apmixedsys.c does not call
platform_set_drvdata(), but clk_mt8192_apmixed_remove() callback calls
platform_get_drvdata().
This results in platform_get_drvdata() returning NULL,
which leads to calling kfree(NULL) in mtk_free_clk_data(NULL).
This leaves clk_data unreleased, causing a memory leak.

Fix this by calling platform_set_drvdata() during probe.

Fixes: 124294ff468f ("clk: mediatek: mt8192: Move apmixedsys clock driver to its own file")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Akari Tsuyukusa <akkun11.open@xxxxxxxxx>
Reviewed-by: Brian Masney <bmasney@xxxxxxxxxx>
---
drivers/clk/mediatek/clk-mt8192-apmixedsys.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/clk/mediatek/clk-mt8192-apmixedsys.c b/drivers/clk/mediatek/clk-mt8192-apmixedsys.c
index b0563a285bd6..e6ac40e2f12d 100644
--- a/drivers/clk/mediatek/clk-mt8192-apmixedsys.c
+++ b/drivers/clk/mediatek/clk-mt8192-apmixedsys.c
@@ -176,6 +176,8 @@ static int clk_mt8192_apmixed_probe(struct platform_device *pdev)
if (r)
goto unregister_gates;

+ platform_set_drvdata(pdev, clk_data);
+
return r;

unregister_gates:
--
2.55.0