From: Kai Vehmanen Date: Fri, 24 Jan 2020 21:36:22 +0000 (-0600) Subject: ASoC: SOF: trace: fix unconditional free in trace release X-Git-Tag: v5.6-rc1~42^2~3^2~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e6110114d18d330c05fd6de9f31283fd086a5a3a;p=thirdparty%2Flinux.git ASoC: SOF: trace: fix unconditional free in trace release Check if DMA pages were successfully allocated in initialization before calling free. For many types of memory (like sgbufs) the extra free is harmless, but not all backends track allocation state, so add an explicit check. Signed-off-by: Kai Vehmanen Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200124213625.30186-5-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- diff --git a/sound/soc/sof/trace.c b/sound/soc/sof/trace.c index 4bb65030819d3..d815090252f86 100644 --- a/sound/soc/sof/trace.c +++ b/sound/soc/sof/trace.c @@ -343,7 +343,10 @@ void snd_sof_free_trace(struct snd_sof_dev *sdev) snd_sof_release_trace(sdev); - snd_dma_free_pages(&sdev->dmatb); - snd_dma_free_pages(&sdev->dmatp); + if (sdev->dma_trace_pages) { + snd_dma_free_pages(&sdev->dmatb); + snd_dma_free_pages(&sdev->dmatp); + sdev->dma_trace_pages = 0; + } } EXPORT_SYMBOL(snd_sof_free_trace);