diff options
author | Trevor Wu <trevor.wu@mediatek.com> | 2023-06-01 11:33:17 +0800 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2023-06-01 12:30:35 +0100 |
commit | fd67a7a1a22ce47fcbc094c4b6e164c34c652cbe (patch) | |
tree | 9036dd42597dabce11dca87c19b138773c28a290 /sound/soc/mediatek/mt8188/mt8188-afe-clk.c | |
parent | 57d1e8900495cf1751cec74db16fe1a0fe47efbb (diff) | |
download | lwn-fd67a7a1a22ce47fcbc094c4b6e164c34c652cbe.tar.gz lwn-fd67a7a1a22ce47fcbc094c4b6e164c34c652cbe.zip |
ASoC: mediatek: mt8188: fix use-after-free in driver remove path
During mt8188_afe_init_clock(), mt8188_audsys_clk_register() was called
followed by several other devm functions. The caller of
mt8188_afe_init_clock() utilized devm_add_action_or_reset() to call
mt8188_afe_deinit_clock(). However, the order was incorrect, causing a
use-after-free issue during remove time.
At probe time, the order of calls was:
1. mt8188_audsys_clk_register
2. afe_priv->clk = devm_kcalloc
3. afe_priv->clk[i] = devm_clk_get
At remove time, the order of calls was:
1. mt8188_audsys_clk_unregister
3. free afe_priv->clk[i]
2. free afe_priv->clk
To resolve the problem, it's necessary to move devm_add_action_or_reset()
to the appropriate position so that the remove order can be 3->2->1.
Fixes: f6b026479b13 ("ASoC: mediatek: mt8188: support audio clock control")
Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20230601033318.10408-2-trevor.wu@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/mediatek/mt8188/mt8188-afe-clk.c')
-rw-r--r-- | sound/soc/mediatek/mt8188/mt8188-afe-clk.c | 7 |
1 files changed, 0 insertions, 7 deletions
diff --git a/sound/soc/mediatek/mt8188/mt8188-afe-clk.c b/sound/soc/mediatek/mt8188/mt8188-afe-clk.c index 743d6a162cb9..0fb97517f82c 100644 --- a/sound/soc/mediatek/mt8188/mt8188-afe-clk.c +++ b/sound/soc/mediatek/mt8188/mt8188-afe-clk.c @@ -418,13 +418,6 @@ int mt8188_afe_init_clock(struct mtk_base_afe *afe) return 0; } -void mt8188_afe_deinit_clock(void *priv) -{ - struct mtk_base_afe *afe = priv; - - mt8188_audsys_clk_unregister(afe); -} - int mt8188_afe_enable_clk(struct mtk_base_afe *afe, struct clk *clk) { int ret; |