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 <kai.vehmanen@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20200124213625.30186-5-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Kai Vehmanen 2020-01-24 15:36:22 -06:00 committed by Mark Brown
parent 410e5e55c9
commit e6110114d1
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View File

@ -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);