summaryrefslogtreecommitdiffstats
path: root/sound/core/pcm_dmaengine.c
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2015-10-20 11:46:31 +0200
committerVinod Koul <vinod.koul@intel.com>2015-11-16 08:28:52 +0530
commitbc0e7345168c0f7483d2d1da86285d89136417cd (patch)
tree9045e7f4f133da72296fdf13c9270db34d64906a /sound/core/pcm_dmaengine.c
parent860dd64c4382709a276eb4b7ef36596579dba04a (diff)
downloadlinux-stable-bc0e7345168c0f7483d2d1da86285d89136417cd.tar.gz
linux-stable-bc0e7345168c0f7483d2d1da86285d89136417cd.tar.bz2
linux-stable-bc0e7345168c0f7483d2d1da86285d89136417cd.zip
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. 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>
Diffstat (limited to 'sound/core/pcm_dmaengine.c')
-rw-r--r--sound/core/pcm_dmaengine.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sound/core/pcm_dmaengine.c b/sound/core/pcm_dmaengine.c
index fba365a78390..697c166acf05 100644
--- a/sound/core/pcm_dmaengine.c
+++ b/sound/core/pcm_dmaengine.c
@@ -202,13 +202,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;
@@ -346,6 +346,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;
@@ -362,9 +363,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);