Tizen: ion: Fix dma_buf refcount issue in get_ion_handle_from_dmabuf
authorRohit kumar <rohit.kr@samsung.com>
Mon, 11 Jan 2016 09:50:13 +0000 (15:20 +0530)
committerJoonyoung Shim <jy0922.shim@samsung.com>
Wed, 13 Jan 2016 01:29:25 +0000 (10:29 +0900)
Change-Id: If9eef4cc5dcdf89e89af062a56607b01e3640c25
Signed-off-by: Rohit kumar <rohit.kr@samsung.com>
drivers/staging/android/ion/ion.c

index 54337be..fea70ba 100644 (file)
@@ -1312,7 +1312,6 @@ struct ion_handle *get_ion_handle_from_dmabuf(struct ion_client *client, struct
        if (dmabuf->ops != &dma_buf_ops) {
                pr_err("%s: can not import dmabuf from another exporter\n",
                                __func__);
-               dma_buf_put(dmabuf);
                return ERR_PTR(-EINVAL);
        }
        buffer = dmabuf->priv;
@@ -1340,7 +1339,6 @@ struct ion_handle *get_ion_handle_from_dmabuf(struct ion_client *client, struct
        }
 
 end:
-       dma_buf_put(dmabuf);
        return handle;
 }
 EXPORT_SYMBOL(get_ion_handle_from_dmabuf);
@@ -1348,6 +1346,7 @@ EXPORT_SYMBOL(get_ion_handle_from_dmabuf);
 struct ion_handle *ion_import_dma_buf(struct ion_client *client, int fd)
 {
        struct dma_buf *dmabuf;
+       struct ion_handle *handle;
 
        dmabuf = dma_buf_get(fd);
        if (IS_ERR(dmabuf)) {
@@ -1355,7 +1354,9 @@ struct ion_handle *ion_import_dma_buf(struct ion_client *client, int fd)
                                (unsigned long)dmabuf, fd);
                return ERR_PTR(PTR_ERR(dmabuf));
        }
-       return get_ion_handle_from_dmabuf(client, dmabuf);
+       handle = get_ion_handle_from_dmabuf(client, dmabuf);
+       dma_buf_put(dmabuf);
+       return handle;
 }
 EXPORT_SYMBOL(ion_import_dma_buf);