mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 20:07:46 +09:00
UPSTREAM: ALSA: pcm_dmaengine: Properly synchronize DMA on shutdown
Use the new dmaengine_synchronize() function to make sure that all complete
callbacks have finished running before the runtime data, which is accessed
in the completed callback, is freed.
This fixes a long standing use-after-free race condition that has been
observed on some systems.
Change-Id: Id99a1acaa2db537fcee6d10ecc94c831bb0a6faa
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
(cherry picked from commit bc0e734516)
This commit is contained in:
committed by
Tao Huang
parent
12ffbc5dbd
commit
f7fbeb90fd
@@ -305,13 +305,13 @@ int snd_dmaengine_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
|
||||
if (runtime->info & SNDRV_PCM_INFO_PAUSE)
|
||||
dmaengine_pause(prtd->dma_chan);
|
||||
else
|
||||
dmaengine_terminate_all(prtd->dma_chan);
|
||||
dmaengine_terminate_async(prtd->dma_chan);
|
||||
break;
|
||||
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
|
||||
dmaengine_pause(prtd->dma_chan);
|
||||
break;
|
||||
case SNDRV_PCM_TRIGGER_STOP:
|
||||
dmaengine_terminate_all(prtd->dma_chan);
|
||||
dmaengine_terminate_async(prtd->dma_chan);
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
@@ -450,6 +450,7 @@ int snd_dmaengine_pcm_close(struct snd_pcm_substream *substream)
|
||||
{
|
||||
struct dmaengine_pcm_runtime_data *prtd = substream_to_prtd(substream);
|
||||
|
||||
dmaengine_synchronize(prtd->dma_chan);
|
||||
kfree(prtd);
|
||||
|
||||
return 0;
|
||||
@@ -466,9 +467,11 @@ int snd_dmaengine_pcm_close_release_chan(struct snd_pcm_substream *substream)
|
||||
{
|
||||
struct dmaengine_pcm_runtime_data *prtd = substream_to_prtd(substream);
|
||||
|
||||
dmaengine_synchronize(prtd->dma_chan);
|
||||
dma_release_channel(prtd->dma_chan);
|
||||
kfree(prtd);
|
||||
|
||||
return snd_dmaengine_pcm_close(substream);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_close_release_chan);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user