Revision dc93f0dcb436dfd24a06c5b3c0f4c5cd9296e8e5 authored by Trevor Wu on 01 June 2023, 03:33:18 UTC, committed by Mark Brown on 01 June 2023, 11:30:36 UTC
During mt8195_afe_init_clock(), mt8195_audsys_clk_register() was called followed by several other devm functions. At mt8195_afe_deinit_clock() located at mt8195_afe_pcm_dev_remove(), mt8195_audsys_clk_unregister() was called. However, there was an issue with the order in which these functions were called. Specifically, the remove callback of platform_driver was called before devres released the resource, resulting in a use-after-free issue during remove time. At probe time, the order of calls was: 1. mt8195_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. mt8195_audsys_clk_unregister 3. free afe_priv->clk[i] 2. free afe_priv->clk To resolve the problem, we can utilize devm_add_action_or_reset() in mt8195_audsys_clk_register() so that the remove order can be changed to 3->2->1. Fixes: 6746cc858259 ("ASoC: mediatek: mt8195: add platform driver") 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-3-trevor.wu@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent fd67a7a
File | Mode | Size |
---|---|---|
Makefile | -rw-r--r-- | 361 bytes |
compat.c | -rw-r--r-- | 2.2 KB |
ipc_sysctl.c | -rw-r--r-- | 7.2 KB |
mq_sysctl.c | -rw-r--r-- | 3.0 KB |
mqueue.c | -rw-r--r-- | 43.7 KB |
msg.c | -rw-r--r-- | 32.3 KB |
msgutil.c | -rw-r--r-- | 3.6 KB |
namespace.c | -rw-r--r-- | 5.8 KB |
sem.c | -rw-r--r-- | 63.2 KB |
shm.c | -rw-r--r-- | 45.0 KB |
syscall.c | -rw-r--r-- | 5.1 KB |
util.c | -rw-r--r-- | 24.2 KB |
util.h | -rw-r--r-- | 8.8 KB |
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...