ASoC: dpcm: acquire dpcm_lock in dpcm_do_trigger()
A message that is not in the archive (sent off-list or not yet received): CGME20210303060125epcas2p2f8bd60105935980a670a72f8481ddf00@epcas2p2.samsung.com
v5 cover ASoC: dpcm: acquire dpcm_lock in dpcm_do_trigger()
Quoted 17 lines · Takashi Iwai
Quoted 15 lines · Gyeongtaek Lee
If stop by underrun and DPCM BE disconnection is run simultaneously, data abort can be occurred by the sequence below.
CPU0 CPU1
dpcm_be_dai_trigger():dpcm_be_disconnect():
for_each_dpcm_be(fe, stream, dpcm){spin_lock_irqsave(&fe->card->dpcm_lock, flags); list_del(&dpcm->list_be); list_del(&dpcm->list_fe); spin_unlock_irqrestore(&fe->card->dpcm_lock, flags); kfree(dpcm);
Quoted 7 lines
Quoted 4 lines
struct
snd_soc_pcm_runtime*be =dpcm->be; <-- Accessing freed memoryTo prevent this situation,
dpcm_lockshould be acquired during iteration of dpcm list indpcm_be_dai_trigger().I don't think we can apply spin lock there blindly. There is non-atomic PCM that must not take a spin lock there, too.
Hi, Takashi
I fixed the patch to hold dpcm_lock during accessing dpcm related data only, not on the trigger callback of driver.
Thank you.
Gyeongtaek Lee
Quoted 6 lines
thanks,
Takashi
Gyeongtaek Lee (1):
ASoC: dpcm: acquire dpcm_lock in dpcm_do_trigger()
include/sound/soc-dpcm.h | 5 ++++ sound/soc/soc-pcm.c | 59 +++++++++++++++++++++++++++++++++------- 2 files changed, 54 insertions(+), 10 deletions(-)
base-commit: fe07bfda2fb9cdef8a4d4008a409bb02f35f1bd8
Signature · 1 line
2.21.0