Skip to content

Commit 355aecc

Browse files
committed
lib: dma: free dma channels when ref count is 0
Free the memory allocated for DMA channels when the ref count is 0 when using native zephyr drivers. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
1 parent 4ab225b commit 355aecc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/lib/dma.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ void dma_put(struct dma *dma)
128128
k_spinlock_key_t key;
129129

130130
key = k_spin_lock(&dma->lock);
131-
--dma->sref;
131+
if (--dma->sref == 0) {
132+
rfree(dma->chan);
133+
dma->chan = NULL;
134+
}
132135

133136
tr_info(&dma_tr, "dma_put(), dma = %p, sref = %d",
134137
dma, dma->sref);

0 commit comments

Comments
 (0)