Skip to contentSkip to conversation

clk: mediatek: fix memory leak on module removal

PATCH In review Akari Tsuyukusa 2 participants 16 messages Jul 7 – Jul 30

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover clk: mediatek: fix memory leak on module removal

Some MediaTek clock drivers do not call platform_set_drvdata() during probe,
but their 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.

Changes in v2:
- Add a newline between platform_set_drvdata() and return (suggested by Brian Masney)
- Split the patch per SoC, (also suggested by Brian Masney)
- Add "Cc: [email protected]"

Link to v1: https://lore.kernel.org/linux-mediatek/[email protected]/T/#u

Akari Tsuyukusa (6):
clk: mediatek: mt2712: fix memory leak on module removal
clk: mediatek: mt6795: fix memory leak on module removal
clk: mediatek: mt7622: fix memory leak on module removal
clk: mediatek: mt8135: fix memory leak on module removal
clk: mediatek: mt8173: fix memory leak on module removal
clk: mediatek: mt8192: fix memory leak on module removal

 drivers/clk/mediatek/clk-mt2712-apmixedsys.c | 2 ++
 drivers/clk/mediatek/clk-mt6795-apmixedsys.c | 2 ++
 drivers/clk/mediatek/clk-mt6795-infracfg.c   | 2 ++
 drivers/clk/mediatek/clk-mt6795-pericfg.c    | 2 ++
 drivers/clk/mediatek/clk-mt7622-apmixedsys.c | 2 ++
 drivers/clk/mediatek/clk-mt7622-infracfg.c   | 2 ++
 drivers/clk/mediatek/clk-mt8135-apmixedsys.c | 2 ++
 drivers/clk/mediatek/clk-mt8173-apmixedsys.c | 2 ++
 drivers/clk/mediatek/clk-mt8173-infracfg.c   | 2 ++
 drivers/clk/mediatek/clk-mt8192-apmixedsys.c | 2 ++
 10 files changed, 20 insertions(+)
Signature · 1 line
2.54.0
#1 lore raw

PATCH v2 1/6 clk: mediatek: mt2712: fix memory leak on module removal

clk_mt2712_apmixed_probe() in clk-mt2712-apmixedsys.c does not call platform_set_drvdata(), but clk_mt2712_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 c6368ce86435 ("clk: mediatek: mt2712-apmixedsys: Add .remove() callback for module build")
---
 drivers/clk/mediatek/clk-mt2712-apmixedsys.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/clk/mediatek/clk-mt2712-apmixedsys.c +2 -0
index 54b18e9f83f8..087cf574bcdc 100644
@@ -129,6 +129,8 @@ static int clk_mt2712_apmixed_probe(struct platform_device *pdev)
 		goto unregister_plls;
 	}
 
+	platform_set_drvdata(pdev, clk_data);
+
 	return 0;
 
 unregister_plls:
Signature · 1 line
2.54.0
Reviewed-by on v2 1/6
#2 lore raw

Re: [PATCH v2 1/6] clk: mediatek: mt2712: fix memory leak on module removal

Quoted 7 lines · Akari Tsuyukusa

clk_mt2712_apmixed_probe() in clk-mt2712-apmixedsys.c does not call platform_set_drvdata(), but clk_mt2712_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.

Quoted 5 lines

Fix this by calling platform_set_drvdata() during probe.

Fixes c6368ce86435 ("clk: mediatek: mt2712-apmixedsys: Add .remove() callback for module build")
#3 lore raw

PATCH v2 2/6 clk: mediatek: mt6795: fix memory leak on module removal

In reply to Akari Tsuyukusa

clk-mt6795-apmixedsys.c, clk-mt6795-infracfg.c and clk-mt6795-pericfg.c do not call platform_set_drvdata() during their driver probe callback, but their 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 0d363282bb0c ("clk: mediatek: Add MediaTek Helio X10 MT6795 clock drivers")
---
 drivers/clk/mediatek/clk-mt6795-apmixedsys.c | 2 ++
 drivers/clk/mediatek/clk-mt6795-infracfg.c   | 2 ++
 drivers/clk/mediatek/clk-mt6795-pericfg.c    | 2 ++
 3 files changed, 6 insertions(+)
drivers/clk/mediatek/clk-mt6795-apmixedsys.c +2 -0
index 123d5d7fea85..239a3f5e1760 100644
@@ -175,6 +175,8 @@ static int clk_mt6795_apmixed_probe(struct platform_device *pdev)
 	dev_dbg(dev, "Performing initial setup for MD1\n");
 	clk_mt6795_apmixed_setup_md1(base);
 
+	platform_set_drvdata(pdev, clk_data);
+
 	return 0;
 
 unregister_ref2usb:
drivers/clk/mediatek/clk-mt6795-infracfg.c +2 -0
index e4559569f5b0..914bb069aa85 100644
@@ -116,6 +116,8 @@ static int clk_mt6795_infracfg_probe(struct platform_device *pdev)
 	if (ret)
 		goto unregister_cpumuxes;
 
+	platform_set_drvdata(pdev, clk_data);
+
 	return 0;
 
 unregister_cpumuxes:
drivers/clk/mediatek/clk-mt6795-pericfg.c +2 -0
index d48240eb2a67..27d0ef7d7b2f 100644
@@ -125,6 +125,8 @@ static int clk_mt6795_pericfg_probe(struct platform_device *pdev)
 	if (ret)
 		goto unregister_composites;
 
+	platform_set_drvdata(pdev, clk_data);
+
 	return 0;
 
 unregister_composites:
Signature · 1 line
2.54.0
Reviewed-by on v2 2/6
#4 lore raw

Re: [PATCH v2 2/6] clk: mediatek: mt6795: fix memory leak on module removal

Quoted 7 lines · Akari Tsuyukusa

clk-mt6795-apmixedsys.c, clk-mt6795-infracfg.c and clk-mt6795-pericfg.c do not call platform_set_drvdata() during their driver probe callback, but their 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.

Quoted 5 lines

Fix this by calling platform_set_drvdata() during probe.

Fixes 0d363282bb0c ("clk: mediatek: Add MediaTek Helio X10 MT6795 clock drivers")
#5 lore raw

PATCH v2 3/6 clk: mediatek: mt7622: fix memory leak on module removal

In reply to Akari Tsuyukusa

clk-mt7622-apmixedsys.c and clk-mt7622-infracfg.c do not call platform_set_drvdata() during their driver probe callback, but their 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 c50e2ea6507b ("clk: mediatek: mt7622-apmixedsys: Add .remove() callback for module build")
Fixes 838b86331c5e ("clk: mediatek: mt7622: Move infracfg to clk-mt7622-infracfg.c")
---
 drivers/clk/mediatek/clk-mt7622-apmixedsys.c | 2 ++
 drivers/clk/mediatek/clk-mt7622-infracfg.c   | 2 ++
 2 files changed, 4 insertions(+)
drivers/clk/mediatek/clk-mt7622-apmixedsys.c +2 -0
index 8a29eaab0cfc..fae8abda14b3 100644
@@ -109,6 +109,8 @@ static int clk_mt7622_apmixed_probe(struct platform_device *pdev)
 	if (ret)
 		goto unregister_gates;
 
+	platform_set_drvdata(pdev, clk_data);
+
 	return 0;
 
 unregister_gates:
drivers/clk/mediatek/clk-mt7622-infracfg.c +2 -0
index cfdf3b07c3e0..cec19447d637 100644
@@ -90,6 +90,8 @@ static int clk_mt7622_infracfg_probe(struct platform_device *pdev)
 	if (ret)
 		goto unregister_cpumuxes;
 
+	platform_set_drvdata(pdev, clk_data);
+
 	return 0;
 
 unregister_cpumuxes:
Signature · 1 line
2.54.0
Reviewed-by on v2 3/6
#6 lore raw

Re: [PATCH v2 3/6] clk: mediatek: mt7622: fix memory leak on module removal

Quoted 7 lines · Akari Tsuyukusa

clk-mt7622-apmixedsys.c and clk-mt7622-infracfg.c do not call platform_set_drvdata() during their driver probe callback, but their 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.

Quoted 6 lines

Fix this by calling platform_set_drvdata() during probe.

Fixes c50e2ea6507b ("clk: mediatek: mt7622-apmixedsys: Add .remove() callback for module build")
Fixes 838b86331c5e ("clk: mediatek: mt7622: Move infracfg to clk-mt7622-infracfg.c")
#7 lore raw

PATCH v2 4/6 clk: mediatek: mt8135: fix memory leak on module removal

In reply to Akari Tsuyukusa

clk_mt8135_apmixed_probe() in clk-mt8135-apmixedsys.c does not call platform_set_drvdata(), but clk_mt8135_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 54b7026f011e ("clk: mediatek: mt8135-apmixedsys: Convert to platform_driver and module")
---
 drivers/clk/mediatek/clk-mt8135-apmixedsys.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/clk/mediatek/clk-mt8135-apmixedsys.c +2 -0
index 19e4ee489ec3..e3b7dc13b458 100644
@@ -66,6 +66,8 @@ static int clk_mt8135_apmixed_probe(struct platform_device *pdev)
 	if (ret)
 		goto unregister_plls;
 
+	platform_set_drvdata(pdev, clk_data);
+
 	return 0;
 
 unregister_plls:
Signature · 1 line
2.54.0
Reviewed-by on v2 4/6
#8 lore raw

Re: [PATCH v2 4/6] clk: mediatek: mt8135: fix memory leak on module removal

Quoted 7 lines · Akari Tsuyukusa

clk_mt8135_apmixed_probe() in clk-mt8135-apmixedsys.c does not call platform_set_drvdata(), but clk_mt8135_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.

Quoted 5 lines

Fix this by calling platform_set_drvdata() during probe.

Fixes 54b7026f011e ("clk: mediatek: mt8135-apmixedsys: Convert to platform_driver and module")
#9 lore raw

PATCH v2 5/6 clk: mediatek: mt8173: fix memory leak on module removal

In reply to Akari Tsuyukusa

clk-mt8173-apmixedsys.c and clk-mt8173-infracfg.c do not call platform_set_drvdata() during their driver probe callback, but their 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 4c02c9af3cb9 ("clk: mediatek: mt8173: Break down clock drivers and allow module build")
---
 drivers/clk/mediatek/clk-mt8173-apmixedsys.c | 2 ++
 drivers/clk/mediatek/clk-mt8173-infracfg.c   | 2 ++
 2 files changed, 4 insertions(+)
drivers/clk/mediatek/clk-mt8173-apmixedsys.c +2 -0
index d7d416172ab3..65dc4489a09c 100644
@@ -179,6 +179,8 @@ static int clk_mt8173_apmixed_probe(struct platform_device *pdev)
 	if (r)
 		goto unregister_ref2usb;
 
+	platform_set_drvdata(pdev, clk_data);
+
 	return 0;
 
 unregister_ref2usb:
drivers/clk/mediatek/clk-mt8173-infracfg.c +2 -0
index fa2d1d557e04..8b69009e1965 100644
@@ -128,6 +128,8 @@ static int clk_mt8173_infracfg_probe(struct platform_device *pdev)
 	if (r)
 		goto unregister_clk_hw;
 
+	platform_set_drvdata(pdev, clk_data);
+
 	return 0;
 
 unregister_clk_hw:
Signature · 1 line
2.54.0
Reviewed-by on v2 5/6
#10 lore raw

Re: [PATCH v2 5/6] clk: mediatek: mt8173: fix memory leak on module removal

Quoted 7 lines · Akari Tsuyukusa

clk-mt8173-apmixedsys.c and clk-mt8173-infracfg.c do not call platform_set_drvdata() during their driver probe callback, but their 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.

Quoted 5 lines

Fix this by calling platform_set_drvdata() during probe.

Fixes 4c02c9af3cb9 ("clk: mediatek: mt8173: Break down clock drivers and allow module build")
#11 lore raw

Re: [PATCH v2 5/6] clk: mediatek: mt8173: fix memory leak on module removal

In reply to Akari Tsuyukusa

Hi Akari,

Quoted 35 lines · Akari Tsuyukusa

clk-mt8173-apmixedsys.c and clk-mt8173-infracfg.c do not call platform_set_drvdata() during their driver probe callback, but their 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 4c02c9af3cb9 ("clk: mediatek: mt8173: Break down clock drivers and allow module build")
---
 drivers/clk/mediatek/clk-mt8173-apmixedsys.c | 2 ++
 drivers/clk/mediatek/clk-mt8173-infracfg.c   | 2 ++
 2 files changed, 4 insertions(+)
drivers/clk/mediatek/clk-mt8173-apmixedsys.c +2 -0
index d7d416172ab3..65dc4489a09c 100644
@@ -179,6 +179,8 @@ static int clk_mt8173_apmixed_probe(struct platform_device *pdev)
 	if (r)
 		goto unregister_ref2usb;
 
+	platform_set_drvdata(pdev, clk_data);
+
 	return 0;
 
 unregister_ref2usb:
drivers/clk/mediatek/clk-mt8173-infracfg.c +0 -0
index fa2d1d557e04..8b69009e1965 100644

drivers/clk/mediatek/clk-mt8173-infracfg.c static int clk_mt8173_infracfg_probe(struct platform_device *pdev) · line 132

Quoted 5 lines
drivers/clk/mediatek/clk-mt8173-infracfg.c +2 -0
@@ -128,6 +128,8 @@ static int clk_mt8173_infracfg_probe(struct platform_device *pdev)
 	if (r)
 		goto unregister_clk_hw;
 
+	platform_set_drvdata(pdev, clk_data);
+

This patch doesn't compile.

drivers/clk/mediatek/clk-mt8173-infracfg.c: In function ‘clk_mt8173_infracfg_probe’:
drivers/clk/mediatek/clk-mt8173-infracfg.c:131:36: error: ‘clk_data’ undeclared (first use in this function); did you mean ‘clk_gate’?

Brian

#12 lore raw

Re: [PATCH v2 5/6] clk: mediatek: mt8173: fix memory leak on module removal

Hi Brian,

Quoted 39 lines · Brian Masney
Quoted 38 lines · Akari Tsuyukusa

clk-mt8173-apmixedsys.c and clk-mt8173-infracfg.c do not call platform_set_drvdata() during their driver probe callback, but their 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 4c02c9af3cb9 ("clk: mediatek: mt8173: Break down clock drivers and allow module build")
---
 drivers/clk/mediatek/clk-mt8173-apmixedsys.c | 2 ++
 drivers/clk/mediatek/clk-mt8173-infracfg.c   | 2 ++
 2 files changed, 4 insertions(+)
drivers/clk/mediatek/clk-mt8173-apmixedsys.c +2 -0
index d7d416172ab3..65dc4489a09c 100644
@@ -179,6 +179,8 @@ static int clk_mt8173_apmixed_probe(struct platform_device *pdev)
 	if (r)
 		goto unregister_ref2usb;
 
+	platform_set_drvdata(pdev, clk_data);
+
 	return 0;
 
 unregister_ref2usb:
drivers/clk/mediatek/clk-mt8173-infracfg.c +0 -0
index fa2d1d557e04..8b69009e1965 100644
@@ -128,6 +128,8 @@ static int clk_mt8173_infracfg_probe(struct platform_device *pdev)
 	if (r)
 		goto unregister_clk_hw;
 
Quoted 7 lines

drivers/clk/mediatek/clk-mt8173-infracfg.c static int clk_mt8173_infracfg_probe(struct platform_device *pdev) · line 132

Quoted 2 lines
drivers/clk/mediatek/clk-mt8173-infracfg.c +2 -0
+	platform_set_drvdata(pdev, clk_data);
+

This patch doesn't compile.

drivers/clk/mediatek/clk-mt8173-infracfg.c: In function ‘clk_mt8173_infracfg_probe’:
drivers/clk/mediatek/clk-mt8173-infracfg.c:131:36: error: ‘clk_data’ undeclared (first use in this function); did you mean ‘clk_gate’?

Sorry for sending you a broken patch.
I accidentally built only with ARCH=arm and missed the build failure.

While fixing this, I noticed that clk-mt8173-infracfg.c can be converted to use mtk_clk_simple_probe()/remove() instead of adding driver-specific drvdata handling.

The helper currently lacks cpumux support, but I have a reviewed patch for it:
https://lore.kernel.org/lkml/[email protected]/
(Reviewed-by: Chen-Yu Tsai <[email protected]>)

Also, adding PLL support to the helper should allow more MediaTek clock drivers to use the common probe/remove path:
https://github.com/TeamYogaBlade2/linux/commit/d991a61887ab76fd83708dffe8e48192e01023d5

Would it be preferable to extend mtk_clk_simple_probe()/remove() with cpumux and PLL support and reorganize this series around it? or should I keep this series focused on the current simple fixes?

Best Regards,
Akari

#13 lore raw

Re: [PATCH v2 5/6] clk: mediatek: mt8173: fix memory leak on module removal

Hi Akari,

Quoted 60 lines · Akari Tsuyukusa
Quoted 39 lines · Brian Masney
Quoted 38 lines · Akari Tsuyukusa

clk-mt8173-apmixedsys.c and clk-mt8173-infracfg.c do not call platform_set_drvdata() during their driver probe callback, but their 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 4c02c9af3cb9 ("clk: mediatek: mt8173: Break down clock drivers and allow module build")
---
 drivers/clk/mediatek/clk-mt8173-apmixedsys.c | 2 ++
 drivers/clk/mediatek/clk-mt8173-infracfg.c   | 2 ++
 2 files changed, 4 insertions(+)
drivers/clk/mediatek/clk-mt8173-apmixedsys.c +2 -0
index d7d416172ab3..65dc4489a09c 100644
@@ -179,6 +179,8 @@ static int clk_mt8173_apmixed_probe(struct platform_device *pdev)
 	if (r)
 		goto unregister_ref2usb;
 
+	platform_set_drvdata(pdev, clk_data);
+
 	return 0;
 
 unregister_ref2usb:
drivers/clk/mediatek/clk-mt8173-infracfg.c +0 -0
index fa2d1d557e04..8b69009e1965 100644
@@ -128,6 +128,8 @@ static int clk_mt8173_infracfg_probe(struct platform_device *pdev)
 	if (r)
 		goto unregister_clk_hw;
 
Quoted 7 lines

drivers/clk/mediatek/clk-mt8173-infracfg.c static int clk_mt8173_infracfg_probe(struct platform_device *pdev) · line 132

Quoted 2 lines
drivers/clk/mediatek/clk-mt8173-infracfg.c +2 -0
+	platform_set_drvdata(pdev, clk_data);
+

This patch doesn't compile.

drivers/clk/mediatek/clk-mt8173-infracfg.c: In function ‘clk_mt8173_infracfg_probe’:
drivers/clk/mediatek/clk-mt8173-infracfg.c:131:36: error: ‘clk_data’ undeclared (first use in this function); did you mean ‘clk_gate’?

Sorry for sending you a broken patch.
I accidentally built only with ARCH=arm and missed the build failure.

While fixing this, I noticed that clk-mt8173-infracfg.c can be converted to use mtk_clk_simple_probe()/remove() instead of adding driver-specific drvdata handling.

The helper currently lacks cpumux support, but I have a reviewed patch for it:
https://lore.kernel.org/lkml/[email protected]/
(Reviewed-by: Chen-Yu Tsai <[email protected]>)

Quoted 6 lines

Also, adding PLL support to the helper should allow more MediaTek clock drivers to use the common probe/remove path:
https://github.com/TeamYogaBlade2/linux/commit/d991a61887ab76fd83708dffe8e48192e01023d5

Would it be preferable to extend mtk_clk_simple_probe()/remove() with cpumux and PLL support and reorganize this series around it?

Yes, that sounds good.

Brian

#14 lore raw

PATCH v2 6/6 clk: mediatek: mt8192: fix memory leak on module removal

In reply to Akari Tsuyukusa

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")
---
 drivers/clk/mediatek/clk-mt8192-apmixedsys.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/clk/mediatek/clk-mt8192-apmixedsys.c +2 -0
index b0563a285bd6..e6ac40e2f12d 100644
@@ -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:
Signature · 1 line
2.54.0
Reviewed-by on v2 6/6
#15 lore raw

Re: [PATCH v2 6/6] clk: mediatek: mt8192: fix memory leak on module removal

Quoted 7 lines · Akari Tsuyukusa

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.

Quoted 5 lines

Fix this by calling platform_set_drvdata() during probe.

Fixes 124294ff468f ("clk: mediatek: mt8192: Move apmixedsys clock driver to its own file")