From 9c69ccfce6fb34d7fb02e443990ab2b82fa2953f Mon Sep 17 00:00:00 2001 From: Karthikeyan Mani Date: Mon, 15 Oct 2018 12:21:06 -0700 Subject: [PATCH] dsp: msm_audio_ion: unmap dma only if unmap kernel succeeds If buf unmap is executed without successful kernel unmap the vmap counter mismatches. Check for error scenarios in kernel unmap function and ignore buf unmap if not necessary. Change-Id: I3c5835dcdfe05db4baaa5cf904995ed8f89e9cfe Signed-off-by: Karthikeyan Mani --- dsp/msm_audio_ion.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dsp/msm_audio_ion.c b/dsp/msm_audio_ion.c index 5a80916c1f84..bf3ef1250ed4 100644 --- a/dsp/msm_audio_ion.c +++ b/dsp/msm_audio_ion.c @@ -279,7 +279,7 @@ exit: return addr; } -static void msm_audio_ion_unmap_kernel(struct dma_buf *dma_buf) +static int msm_audio_ion_unmap_kernel(struct dma_buf *dma_buf) { int rc = 0; void *vaddr = NULL; @@ -304,6 +304,7 @@ static void msm_audio_ion_unmap_kernel(struct dma_buf *dma_buf) dev_err(cb_dev, "%s: cannot find allocation for dma_buf %pK", __func__, dma_buf); + rc = -EINVAL; goto err; } @@ -317,7 +318,7 @@ static void msm_audio_ion_unmap_kernel(struct dma_buf *dma_buf) } err: - return; + return rc; } static int msm_audio_ion_map_buf(struct dma_buf *dma_buf, dma_addr_t *paddr, @@ -489,12 +490,16 @@ EXPORT_SYMBOL(msm_audio_ion_import); */ int msm_audio_ion_free(struct dma_buf *dma_buf) { + int ret = 0; + if (!dma_buf) { pr_err("%s: dma_buf invalid\n", __func__); return -EINVAL; } - msm_audio_ion_unmap_kernel(dma_buf); + ret = msm_audio_ion_unmap_kernel(dma_buf); + if (ret) + return ret; msm_audio_dma_buf_unmap(dma_buf);