5 Jun
2023
5 Jun
'23
3:21 p.m.
On 01/06/2023 05:33, Trevor Wu wrote:
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:
- mt8188_audsys_clk_register
- afe_priv->clk = devm_kcalloc
- afe_priv->clk[i] = devm_clk_get
At remove time, the order of calls was:
- mt8188_audsys_clk_unregister
- free afe_priv->clk[i]
- 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.
Sounds good
Reviewed-by: Alexandre Mergnat amergnat@baylibre.com
--
Regards,
Alexandre