[PATCH] clk: mediatek: fix memory leak on module removal#57
Draft
akku1139 wants to merge 1 commit into
Draft
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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")