We shouldn't vunmap more then we vmap, but if we do, make sure we complain loudly.
Cc: Sumit Semwal <sumit.sem...@linaro.org> Cc: Liam Mark <lm...@codeaurora.org> Cc: Laura Abbott <labb...@kernel.org> Cc: Brian Starkey <brian.star...@arm.com> Cc: Hridya Valsaraju <hri...@google.com> Cc: Suren Baghdasaryan <sur...@google.com> Cc: Sandeep Patil <sspa...@google.com> Cc: Daniel Mentz <danielme...@google.com> Cc: Chris Goldsworthy <cgold...@codeaurora.org> Cc: Ørjan Eide <orjan.e...@arm.com> Cc: Robin Murphy <robin.mur...@arm.com> Cc: Ezequiel Garcia <ezequ...@collabora.com> Cc: Simon Ser <cont...@emersion.fr> Cc: James Jones <jajo...@nvidia.com> Cc: linux-me...@vger.kernel.org Cc: dri-de...@lists.freedesktop.org Suggested-by: Suren Baghdasaryan <sur...@google.com> Signed-off-by: John Stultz <john.stu...@linaro.org> --- drivers/dma-buf/heaps/cma_heap.c | 1 + drivers/dma-buf/heaps/system_heap.c | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma_heap.c index 364fc2f3e499..0c76cbc3fb11 100644 --- a/drivers/dma-buf/heaps/cma_heap.c +++ b/drivers/dma-buf/heaps/cma_heap.c @@ -232,6 +232,7 @@ static void cma_heap_vunmap(struct dma_buf *dmabuf, struct dma_buf_map *map) struct cma_heap_buffer *buffer = dmabuf->priv; mutex_lock(&buffer->lock); + WARN_ON(buffer->vmap_cnt == 0); if (!--buffer->vmap_cnt) { vunmap(buffer->vaddr); buffer->vaddr = NULL; diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c index 405351aad2a8..2321c91891f6 100644 --- a/drivers/dma-buf/heaps/system_heap.c +++ b/drivers/dma-buf/heaps/system_heap.c @@ -273,6 +273,7 @@ static void system_heap_vunmap(struct dma_buf *dmabuf, struct dma_buf_map *map) struct system_heap_buffer *buffer = dmabuf->priv; mutex_lock(&buffer->lock); + WARN_ON(buffer->vmap_cnt == 0); if (!--buffer->vmap_cnt) { vunmap(buffer->vaddr); buffer->vaddr = NULL; -- 2.17.1