linux-stable/sound/soc
Trevor Wu dc93f0dcb4
ASoC: mediatek: mt8195: fix use-after-free in driver remove path
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: 6746cc8582 ("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>
2023-06-01 12:30:36 +01:00
..
adi ASoC: adi: axi-spdif: Convert to platform remove callback returning void 2023-03-20 13:07:10 +00:00
amd ASoC: amd: yc: Add Thinkpad Neo14 to quirks list for acp6x 2023-05-31 12:24:59 +01:00
apple ASoC: apple: mca: Convert to platform remove callback returning void 2023-03-20 13:07:18 +00:00
atmel ASoC: atmel: remove unnecessary dai_link->platform 2023-03-24 12:15:18 +00:00
au1x ASoC: au1x: psc-i2s: Convert to platform remove callback returning void 2023-03-20 13:07:31 +00:00
bcm ASoC: bcm: cygnus-ssp: Convert to platform remove callback returning void 2023-03-20 13:07:33 +00:00
cirrus ASoC: ep93xx: Add OF support 2023-04-12 12:54:23 +01:00
codecs ASoC: nau8824: Add quirk to active-high jack-detect 2023-05-30 13:43:28 +01:00
dwc ASoC: dwc: move DMA init to snd_soc_dai_driver probe() 2023-05-23 21:39:30 +01:00
fsl ASoC: fsl_micfil: Fix error handler with pm_runtime_enable 2023-05-08 22:35:10 +09:00
generic ASoC: simple-card: Add missing of_node_put() in case of error 2023-05-26 16:35:26 +01:00
hisilicon
img ASoC: img: pistachio-internal-dac: Convert to platform remove callback returning void 2023-03-20 13:08:22 +00:00
intel ASoC: Intel: avs: Add missing checks on FE startup 2023-05-22 11:18:26 +01:00
jz4740 ASoC: jz4740-i2s: Make I2S divider calculations more robust 2023-05-11 10:17:58 +09:00
kirkwood ASoC: kirkwood: kirkwood-i2s: Convert to platform remove callback returning void 2023-03-20 13:08:35 +00:00
mediatek ASoC: mediatek: mt8195: fix use-after-free in driver remove path 2023-06-01 12:30:36 +01:00
meson ASoC: meson: switch to use c2c_params instead of params 2023-04-05 12:16:37 +01:00
mxs ASoC: mxs: mxs-sgtl5000: Convert to platform remove callback returning void 2023-03-20 13:08:44 +00:00
pxa ASoC: pxa: pxa2xx-ac97: Convert to platform remove callback returning void 2023-03-20 13:08:46 +00:00
qcom ASoC: qcom: sdw: do not restart soundwire ports for every prepare 2023-04-06 14:45:12 +01:00
rockchip ALSA/ASoC: Convert to platform remove callback 2023-03-21 16:29:48 +00:00
samsung ASoC: samsung: switch to use c2c_params instead of params 2023-04-05 12:16:38 +01:00
sh ASoC: sh: siu_dai: Convert to platform remove callback returning void 2023-03-20 13:09:01 +00:00
sof ASoC: SOF: Intel: hda-mlink: fixes and extensions 2023-05-16 00:13:09 +09:00
spear
sprd ASoC: sprd: sprd-mcdt: Convert to platform remove callback returning void 2023-03-20 13:09:02 +00:00
sti
stm ASoC: stm: stm32_spdifrx: Convert to platform remove callback returning void 2023-03-20 13:09:05 +00:00
sunxi ASoC: sunxi: sun8i-codec: Convert to platform remove callback returning void 2023-03-20 13:09:10 +00:00
tegra ASoC: tegra20_ac97: Add missing unwind goto in tegra20_ac97_platform_probe() 2023-04-04 12:46:42 +01:00
ti ASoC: ti: remove unnecessary dai_link->platform 2023-03-24 12:15:19 +00:00
uniphier ASoC: uniphier: evea: Convert to platform remove callback returning void 2023-03-20 13:09:31 +00:00
ux500 ASoC: ux500: ux500_msp_dai: Convert to platform remove callback returning void 2023-03-20 13:09:32 +00:00
xilinx ASoC: xilinx: xlnx_spdif: Convert to platform remove callback returning void 2023-03-20 13:09:34 +00:00
xtensa ASoC: xtensa: xtfpga-i2s: Convert to platform remove callback returning void 2023-03-20 13:09:35 +00:00
Kconfig
Makefile
soc-ac97.c
soc-acpi.c
soc-card.c
soc-component.c ASoC: expand snd_soc_dpcm_mutex_lock/unlock() 2023-04-17 12:57:25 +01:00
soc-compress.c ASoC: add snd_soc_card_mutex_lock/unlock() 2023-04-17 12:57:26 +01:00
soc-core.c ASoC: add snd_soc_card_mutex_lock/unlock() 2023-04-17 12:57:26 +01:00
soc-dai.c ASoC: soc-dai.c: add missing flag check at snd_soc_pcm_dai_probe() 2023-03-14 13:58:56 +00:00
soc-dapm.c ASoC: expand snd_soc_dapm_mutex_lock/unlock() 2023-04-17 12:57:24 +01:00
soc-devres.c
soc-generic-dmaengine-pcm.c
soc-jack.c
soc-link.c
soc-ops.c
soc-pcm.c ASoC: soc-pcm: test if a BE can be prepared 2023-05-19 02:31:14 +09:00
soc-topology-test.c
soc-topology.c ASoC: soc-topology.c: dai_link->platform again 2023-03-29 17:43:23 +01:00
soc-utils-test.c
soc-utils.c