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

Commit 35822b14 authored by Ravikishore Pampana's avatar Ravikishore Pampana Committed by Gerrit - the friendly Code Review server
Browse files

msm: camera: mem: Validate return value of dma_buf_get



After ion allocation dma_buf_get called to increase the ref count.
Validation is required to know the dma_buf_get success or not.

Change-Id: I1c22b59bbbf9fa5bfe5282217cf1280ea3a265a7
Signed-off-by: default avatarRavikishore Pampana <rpampana@codeaurora.org>
parent 9812e86a
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -426,6 +426,7 @@ static int cam_mem_util_get_dma_buf_fd(size_t len,
	struct dma_buf **buf,
	int *fd)
{
	struct dma_buf *dmabuf = NULL;
	int rc = 0;

	if (!buf || !fd) {
@@ -449,7 +450,11 @@ static int cam_mem_util_get_dma_buf_fd(size_t len,
	 * when we close fd, refcount becomes 1 and when we do
	 * dmap_put_buf, ref count becomes 0 and memory will be freed.
	 */
	dma_buf_get(*fd);
	dmabuf = dma_buf_get(*fd);
	if (IS_ERR_OR_NULL(dmabuf)) {
		CAM_ERR(CAM_MEM, "dma_buf_get failed, *fd=%d", *fd);
		rc = -EINVAL;
	}

	return rc;