diff --git a/dsp/msm_audio_ion.c b/dsp/msm_audio_ion.c index a2f5127be118..566f8bf1b80b 100644 --- a/dsp/msm_audio_ion.c +++ b/dsp/msm_audio_ion.c @@ -316,6 +316,7 @@ static int msm_audio_ion_map_buf(struct dma_buf *dma_buf, dma_addr_t *paddr, if (rc) { pr_err("%s: ION Get Physical for AUDIO failed, rc = %d\n", __func__, rc); + dma_buf_put(dma_buf); goto err; } @@ -323,6 +324,7 @@ static int msm_audio_ion_map_buf(struct dma_buf *dma_buf, dma_addr_t *paddr, if (IS_ERR_OR_NULL(*vaddr)) { pr_err("%s: ION memory mapping for AUDIO failed\n", __func__); rc = -ENOMEM; + msm_audio_dma_buf_unmap(dma_buf); goto err; } @@ -384,17 +386,13 @@ int msm_audio_ion_alloc(struct dma_buf **dma_buf, size_t bufsz, rc = msm_audio_ion_map_buf(*dma_buf, paddr, plen, vaddr); if (rc) { pr_err("%s: failed to map ION buf, rc = %d\n", __func__, rc); - goto err_dma_buf; + goto err; } pr_debug("%s: mapped address = %pK, size=%zd\n", __func__, *vaddr, bufsz); memset(*vaddr, 0, bufsz); - return rc; - -err_dma_buf: - dma_buf_put(*dma_buf); err: return rc; } @@ -488,7 +486,7 @@ int msm_audio_ion_import(struct dma_buf **dma_buf, int fd, rc = msm_audio_ion_map_buf(*dma_buf, paddr, plen, vaddr); if (rc) { pr_err("%s: failed to map ION buf, rc = %d\n", __func__, rc); - goto err_ion_flag; + goto err; } pr_debug("%s: mapped address = %pK, size=%zd\n", __func__, *vaddr, bufsz); diff --git a/dsp/msm_audio_ion_vm.c b/dsp/msm_audio_ion_vm.c index aba015091d5e..fc6039a6bee5 100644 --- a/dsp/msm_audio_ion_vm.c +++ b/dsp/msm_audio_ion_vm.c @@ -547,6 +547,7 @@ static int msm_audio_ion_map_buf(void *handle, dma_addr_t *paddr, if (rc) { pr_err("%s: ION Get Physical for AUDIO failed, rc = %d\n", __func__, rc); + dma_buf_put(dma_buf); goto err; } @@ -554,6 +555,7 @@ static int msm_audio_ion_map_buf(void *handle, dma_addr_t *paddr, if (IS_ERR_OR_NULL(*vaddr)) { pr_err("%s: ION memory mapping for AUDIO failed\n", __func__); rc = -ENOMEM; + msm_audio_dma_buf_unmap(dma_buf); goto err; } @@ -624,7 +626,6 @@ int msm_audio_ion_alloc(void **handle, size_t bufsz, if (rc) { pr_err("%s: failed to map ION buf, rc = %d\n", __func__, rc); - dma_buf_put((struct dma_buf*) *handle); } } else { rc = msm_audio_dma_buf_map(*handle, *vaddr, paddr, @@ -641,7 +642,6 @@ int msm_audio_ion_alloc(void **handle, size_t bufsz, memset(*vaddr, 0, bufsz); - return rc; err: return rc; } @@ -699,7 +699,7 @@ int msm_audio_ion_import(void **handle, int fd, rc = msm_audio_ion_map_buf(*handle, paddr, plen, vaddr); if (rc) { pr_err("%s: failed to map ION buf, rc = %d\n", __func__, rc); - goto err_ion_flag; + goto err; } pr_debug("%s: mapped address = %pK, size=%zd\n", __func__, *vaddr, bufsz);