From 021b9bfe46533ba1dca13d2de8832cfff0a49eb4 Mon Sep 17 00:00:00 2001 From: George Shen Date: Tue, 19 May 2020 16:15:07 -0700 Subject: [PATCH] msm: cvp: Avoids DSP memory leak Call dma_buf put function to decrement dma_buf use count after the buffer is un-mapped from CVP address space. Change-Id: I3007ff8fc55796ae21ee3995ff3456a6e207f804 Signed-off-by: George Shen --- drivers/media/platform/msm/cvp/msm_cvp_buf.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/msm/cvp/msm_cvp_buf.c b/drivers/media/platform/msm/cvp/msm_cvp_buf.c index ee99aad4a3d4..f67c2a25f792 100644 --- a/drivers/media/platform/msm/cvp/msm_cvp_buf.c +++ b/drivers/media/platform/msm/cvp/msm_cvp_buf.c @@ -163,8 +163,10 @@ int msm_cvp_map_buf_dsp(struct msm_cvp_inst *inst, struct cvp_kmd_buffer *buf) return rc; exit: - if (smem->device_addr) + if (smem->device_addr) { msm_cvp_unmap_smem(inst, smem, "unmap dsp"); + msm_cvp_smem_put_dma_buf(smem->dma_buf); + } kmem_cache_free(cvp_driver->buf_cache, cbuf); cbuf = NULL; kmem_cache_free(cvp_driver->smem_cache, smem); @@ -216,8 +218,10 @@ int msm_cvp_unmap_buf_dsp(struct msm_cvp_inst *inst, struct cvp_kmd_buffer *buf) } } - if (cbuf->smem->device_addr) + if (cbuf->smem->device_addr) { msm_cvp_unmap_smem(inst, cbuf->smem, "unmap dsp"); + msm_cvp_smem_put_dma_buf(cbuf->smem->dma_buf); + } mutex_lock(&inst->cvpdspbufs.lock); list_del(&cbuf->list);