]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
staging: android: ion: fix wrong init of dma_buf_export_info
authorSumit Semwal <sumit.semwal@linaro.org>
Sat, 21 Feb 2015 03:30:17 +0000 (09:00 +0530)
committerSumit Semwal <sumit.semwal@linaro.org>
Tue, 21 Apr 2015 09:17:16 +0000 (14:47 +0530)
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>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
drivers/staging/android/ion/ion.c

index b94d69feff46fbea5f2e4227686fd78befcf6b77..b0b96ab31954a98718d1af05121656abc1533e17 100644 (file)
@@ -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);