From 1820be6f7e66e231456fcb853dafe1269df553fb Mon Sep 17 00:00:00 2001 From: Tomasz Lauda Date: Thu, 13 Jun 2019 14:47:20 +0200 Subject: [PATCH] dma: check if sg exists before cache operations Checks if dma_sg_elem_array buffer is allocated before performing cache writeback or invalidation. Signed-off-by: Tomasz Lauda --- src/include/sof/dma.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/include/sof/dma.h b/src/include/sof/dma.h index 82aa542b4..b716698dd 100644 --- a/src/include/sof/dma.h +++ b/src/include/sof/dma.h @@ -330,15 +330,18 @@ void dma_sg_free(struct dma_sg_elem_array *ea); static inline void dma_sg_cache_wb_inv(struct dma_sg_elem_array *ea) { - dcache_writeback_invalidate_region(ea->elems, - ea->count * - sizeof(struct dma_sg_elem)); + if (ea->elems) + dcache_writeback_invalidate_region(ea->elems, + ea->count * + sizeof(struct dma_sg_elem)); } static inline void dma_sg_cache_inv(struct dma_sg_elem_array *ea) { - dcache_invalidate_region(ea->elems, - ea->count * sizeof(struct dma_sg_elem)); + if (ea->elems) + dcache_invalidate_region(ea->elems, + ea->count * + sizeof(struct dma_sg_elem)); } /**