Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ab07f12b authored by Xiaojun Sang's avatar Xiaojun Sang
Browse files

dsp: ion: unmap DMA buffer after kernel ion map failure



DMA buffer does not unmap after kernel ion map failure. It leads
to unexpected vaddr and memory leak.

Change-Id: I363dd9178a0bcbca601180bfd0a7bd7ef2430d3e
Signed-off-by: default avatarXiaojun Sang <xsang@codeaurora.org>
parent 0983e240
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -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);
+3 −3
Original line number Diff line number Diff line
@@ -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);