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 <tomasz.lauda@linux.intel.com>
This commit is contained in:
Tomasz Lauda 2019-06-13 14:47:20 +02:00 committed by Janusz Jankowski
parent 76587ac98a
commit 1820be6f7e
1 changed files with 8 additions and 5 deletions

View File

@ -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));
}
/**