Skip to content

Commit 8f025d3

Browse files
committed
audio: host-zephyr: clean DMA if channel set at free
Add code to check for a valid DMA channel in host_common_free() and if a DMA channel is set, stop the channel and free DMA resources. Issue found in code review. This should not be hit in normal use-cases, but this makes the free implementation more robust in case of errors. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent 3558c49 commit 8f025d3

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/audio/host-zephyr.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,13 @@ __cold void host_common_free(struct host_data *hd)
784784
}
785785
#endif
786786

787+
/* release DMA channel if not already done by reset */
788+
if (hd->chan_index != -EINVAL) {
789+
sof_dma_stop(hd->dma, hd->chan_index);
790+
sof_dma_release_channel(hd->dma, hd->chan_index);
791+
hd->chan_index = -EINVAL;
792+
}
793+
787794
sof_dma_put(hd->dma);
788795

789796
ipc_msg_free(hd->msg);

0 commit comments

Comments
 (0)