Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1643102

[PATCH 3/3] staging: android: ion: Avoid calling free_duped_table() twice

From Archit Taneja <architt@codeaurora.org>
Newsgroups linux.kernel
Subject [PATCH 3/3] staging: android: ion: Avoid calling free_duped_table() twice
Date 2017-05-17 10:20 +0200
Message-ID <tI2lA-AO-19@gated-at.bofh.it> (permalink)
References <tI2lA-AO-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Currently, the duplicated sg table is freed in the detach() and
the error path of map_dma_buf() ion's dma_buf_ops.

If a call to dma_buf_map_attachment() fails, the importer is
expected to call dma_buf_detach() to remove the attachment. This
will result in us trying to free the duped sg table twice.

Don't call free_duped_table() in ion_map_dma_buf() to avoid this.

Signed-off-by: Archit Taneja <architt@codeaurora.org>
---
 drivers/staging/android/ion/ion.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index 90ae6ce466ed..b483e1081309 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -268,20 +268,14 @@ static struct sg_table *ion_map_dma_buf(struct dma_buf_attachment *attachment,
 {
 	struct ion_dma_buf_attachment *a = attachment->priv;
 	struct sg_table *table;
-	int ret;
 
 	table = a->table;
 
 	if (!dma_map_sg(attachment->dev, table->sgl, table->nents,
-			direction)){
-		ret = -ENOMEM;
-		goto err;
-	}
-	return table;
+			direction))
+		return ERR_PTR(-ENOMEM);
 
-err:
-	free_duped_table(table);
-	return ERR_PTR(ret);
+	return table;
 }
 
 static void ion_unmap_dma_buf(struct dma_buf_attachment *attachment,
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/3] staging: android: ion: Minor clean ups and fixes Archit Taneja <architt@codeaurora.org> - 2017-05-17 10:20 +0200
  [PATCH 3/3] staging: android: ion: Avoid calling free_duped_table() twice Archit Taneja <architt@codeaurora.org> - 2017-05-17 10:20 +0200
  [PATCH 1/3] staging: android: ion: Remove unused members from ion_buffer Archit Taneja <architt@codeaurora.org> - 2017-05-17 10:20 +0200
  Re: [PATCH 0/3] staging: android: ion: Minor clean ups and fixes Laura Abbott <labbott@redhat.com> - 2017-05-17 18:40 +0200
  Re: [PATCH 0/3] staging: android: ion: Minor clean ups and fixes Sumit Semwal <sumit.semwal@linaro.org> - 2017-05-18 06:50 +0200

csiph-web