Skip to content

Commit 31f8cab

Browse files
marcanjannau
authored andcommitted
ALSA: dmaengine: Always terminate DMA when a PCM is closed
When a PCM is suspended, we pause the DMA. If the PCM is then closed while in this state, it does not receive the STOP trigger (as it is not running). In this case, we fail to properly terminate the DMA, calling dmaengine_synchronize() nonetheless, which is undefined behavior. Make sure we always call dmaengine_terminate_async() on PCM close, regardless of whether it has been called previously or not in the trigger callbacks. Signed-off-by: Hector Martin <marcan@marcan.st>
1 parent 4c1a237 commit 31f8cab

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

sound/core/pcm_dmaengine.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,11 @@ static void __snd_dmaengine_pcm_close(struct snd_pcm_substream *substream,
353353
if (status == DMA_PAUSED)
354354
dmaengine_terminate_async(prtd->dma_chan);
355355

356+
/*
357+
* The PCM might have been closed while suspended, which would
358+
* skip the STOP trigger. Make sure we terminate.
359+
*/
360+
dmaengine_terminate_async(prtd->dma_chan);
356361
dmaengine_synchronize(prtd->dma_chan);
357362
if (release_channel)
358363
dma_release_channel(prtd->dma_chan);

0 commit comments

Comments
 (0)