Skip to content

[PATCH] clk: mediatek: fix memory leak on module removal#57

Draft
akku1139 wants to merge 1 commit into
mainlinefrom
patch/mtk-apmixed-memoryleak
Draft

[PATCH] clk: mediatek: fix memory leak on module removal#57
akku1139 wants to merge 1 commit into
mainlinefrom
patch/mtk-apmixed-memoryleak

Conversation

@akku1139

Copy link
Copy Markdown
Member

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 mtk_free_clk_data(NULL) -> kfree(NULL).
Therefore, the actual clk_data is never released, causing a memory leak.

Fix this by calling platform_set_drvdata() during probe.

Fixes: 124294f ("clk: mediatek: mt8192: Move apmixedsys clock driver to its own file")
Fixes: 4c02c9a ("clk: mediatek: mt8173: Break down clock drivers and allow module build")
Fixes: 54b7026 ("clk: mediatek: mt8135-apmixedsys: Convert to platform_driver and module")
Fixes: c50e2ea ("clk: mediatek: mt7622-apmixedsys: Add .remove() callback for module build")
Fixes: 0d36328 ("clk: mediatek: Add MediaTek Helio X10 MT6795 clock drivers")
Fixes: c6368ce ("clk: mediatek: mt2712-apmixedsys: Add .remove() callback for module build")
Fixes: 838b863 ("clk: mediatek: mt7622: Move infracfg to clk-mt7622-infracfg.c")

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
mtk_free_clk_data(NULL) -> kfree(NULL).
Therefore, the actual clk_data is never released, causing a memory leak.

Fix this by calling platform_set_drvdata() during probe.

Fixes: 124294f ("clk: mediatek: mt8192: Move apmixedsys clock driver to its own file")
Fixes: 4c02c9a ("clk: mediatek: mt8173: Break down clock drivers and allow module build")
Fixes: 54b7026 ("clk: mediatek: mt8135-apmixedsys: Convert to platform_driver and module")
Fixes: c50e2ea ("clk: mediatek: mt7622-apmixedsys: Add .remove() callback for module build")
Fixes: 0d36328 ("clk: mediatek: Add MediaTek Helio X10 MT6795 clock drivers")
Fixes: c6368ce ("clk: mediatek: mt2712-apmixedsys: Add .remove() callback for module build")
Fixes: 838b863 ("clk: mediatek: mt7622: Move infracfg to clk-mt7622-infracfg.c")
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
@akku1139

akku1139 commented Jun 29, 2026

Copy link
Copy Markdown
Member Author

@akku1139 akku1139 added the Bug label Jun 29, 2026
@akku1139 akku1139 changed the title clk: mediatek: fix memory leak on module removal [PATCH] clk: mediatek: fix memory leak on module removal Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant