mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rohit kumar <rohit.kr@samsung.com>
To: gregkh@linuxfoundation.org, arve@android.com,
	riandrews@android.com, dan.carpenter@oracle.com,
	sumit.semwal@linaro.org, mitchelh@codeaurora.org,
	akpm@linux-foundation.org, linux@rasmusvillemoes.dk,
	dmitry.kalinkin@gmail.com, elfring@users.sourceforge.net,
	gioh.kim@lge.com, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org
Cc: cpgs@samsung.com, pintu.k@samsung.com, pintu_agarwal@yahoo.com,
	rohit.kr@samsung.com, vishnu.ps@samsung.com,
	sreenathd@samsung.com, c.rajkumar@samsung.com, me.rohit@live.com
Subject: [PATCH 1/1] staging: ion: Fix error handling in ion_buffer_create
Date: Wed, 30 Sep 2015 11:07:35 +0530	[thread overview]
Message-ID: <1443591455-14656-1-git-send-email-rohit.kr@samsung.com> (raw)

This patch fixes error handling case when buffer->pages allocation
fails. Also, it removes unreachable code of checking ret variable
although it is not updated.

Signed-off-by: Rohit kumar <rohit.kr@samsung.com>
---
 drivers/staging/android/ion/ion.c |   14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index 217aa53..af59e4a 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -213,10 +213,10 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
 			"heap->ops->map_dma should return ERR_PTR on error"))
 		table = ERR_PTR(-EINVAL);
 	if (IS_ERR(table)) {
-		heap->ops->free(buffer);
-		kfree(buffer);
-		return ERR_CAST(table);
+		ret = -EINVAL;
+		goto err1;
 	}
+
 	buffer->sg_table = table;
 	if (ion_buffer_fault_user_mappings(buffer)) {
 		int num_pages = PAGE_ALIGN(buffer->size) / PAGE_SIZE;
@@ -226,7 +226,7 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
 		buffer->pages = vmalloc(sizeof(struct page *) * num_pages);
 		if (!buffer->pages) {
 			ret = -ENOMEM;
-			goto err1;
+			goto err;
 		}
 
 		for_each_sg(table->sgl, sg, table->nents, i) {
@@ -235,9 +235,6 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
 			for (j = 0; j < sg->length / PAGE_SIZE; j++)
 				buffer->pages[k++] = page++;
 		}
-
-		if (ret)
-			goto err;
 	}
 
 	buffer->dev = dev;
@@ -261,9 +258,8 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
 
 err:
 	heap->ops->unmap_dma(heap, buffer);
-	heap->ops->free(buffer);
 err1:
-	vfree(buffer->pages);
+	heap->ops->free(buffer);
 err2:
 	kfree(buffer);
 	return ERR_PTR(ret);
-- 
1.7.9.5


             reply	other threads:[~2015-09-30  5:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-30  5:37 Rohit kumar [this message]
2015-09-30 18:12 ` Laura Abbott
2015-10-01  5:31   ` PINTU KUMAR
2015-10-01  6:21     ` Gioh Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1443591455-14656-1-git-send-email-rohit.kr@samsung.com \
    --to=rohit.kr@samsung.com \
    --cc=akpm@linux-foundation.org \
    --cc=arve@android.com \
    --cc=c.rajkumar@samsung.com \
    --cc=cpgs@samsung.com \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=dmitry.kalinkin@gmail.com \
    --cc=elfring@users.sourceforge.net \
    --cc=gioh.kim@lge.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=me.rohit@live.com \
    --cc=mitchelh@codeaurora.org \
    --cc=pintu.k@samsung.com \
    --cc=pintu_agarwal@yahoo.com \
    --cc=riandrews@android.com \
    --cc=sreenathd@samsung.com \
    --cc=sumit.semwal@linaro.org \
    --cc=vishnu.ps@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®