mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sumit Semwal <sumit.semwal@linaro.org>
To: linux-kernel@vger.kernel.org, linaro-mm-sig@lists.linaro.org,
	dan.carpenter@oracle.com, gregkh@linuxfoundation.org
Cc: devel@driverdev.osuosl.org, Sumit Semwal <sumit.semwal@linaro.org>
Subject: [PATCH] staging: android: ion: fix wrong init of dma_buf_export_info
Date: Tue, 24 Feb 2015 17:43:25 +0530	[thread overview]
Message-ID: <1424780005-13966-1-git-send-email-sumit.semwal@linaro.org> (raw)

Fixes: 817bd7253291 ("dma-buf: cleanup dma_buf_export() to make it
easily extensible")

Stupid copy-paste from me in the above patch leads to the following static
checker warning:

        drivers/staging/android/ion/ion.c:1112 ion_share_dma_buf()
        error: potentially dereferencing uninitialized 'buffer'.

drivers/staging/android/ion/ion.c
  1103  struct dma_buf *ion_share_dma_buf(struct ion_client *client,
  1104                                                  struct
ion_handle *handle)
  1105  {
  1106          struct ion_buffer *buffer;
                                   ^^^^^^
  1107          struct dma_buf *dmabuf;
  1108          bool valid_handle;
  1109          DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
  1110
  1111          exp_info.ops = &dma_buf_ops;
  1112          exp_info.size = buffer->size;
                                ^^^^^^
  1113          exp_info.flags = O_RDWR;
  1114          exp_info.priv = buffer;
                                ^^^^^^
And here also.

  1115

This patch corrects this stupidity.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
---
 drivers/staging/android/ion/ion.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index a4297be8f12f..204860a36c29 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -1108,11 +1108,6 @@ struct dma_buf *ion_share_dma_buf(struct ion_client *client,
 	bool valid_handle;
 	DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
 
-	exp_info.ops = &dma_buf_ops;
-	exp_info.size = buffer->size;
-	exp_info.flags = O_RDWR;
-	exp_info.priv = buffer;
-
 	mutex_lock(&client->lock);
 	valid_handle = ion_handle_validate(client, handle);
 	if (!valid_handle) {
@@ -1124,6 +1119,11 @@ struct dma_buf *ion_share_dma_buf(struct ion_client *client,
 	ion_buffer_get(buffer);
 	mutex_unlock(&client->lock);
 
+	exp_info.ops = &dma_buf_ops;
+	exp_info.size = buffer->size;
+	exp_info.flags = O_RDWR;
+	exp_info.priv = buffer;
+
 	dmabuf = dma_buf_export(&exp_info);
 	if (IS_ERR(dmabuf)) {
 		ion_buffer_put(buffer);
-- 
1.9.1


             reply	other threads:[~2015-02-24 12:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-24 12:13 Sumit Semwal [this message]
2015-02-25 10:23 ` Dan Carpenter

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=1424780005-13966-1-git-send-email-sumit.semwal@linaro.org \
    --to=sumit.semwal@linaro.org \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    /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®