]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
video: tegra: nvmap: set handle dmabuf to NULL early
authorKrishna Reddy <vdumpa@nvidia.com>
Tue, 17 Jun 2014 19:30:16 +0000 (12:30 -0700)
committerWinnie Hsu <whsu@nvidia.com>
Fri, 8 Aug 2014 21:41:49 +0000 (14:41 -0700)
This can allow catching handle dmabuf usage during its free.

Bug 1529015

Change-Id: Ie20c7b860ca5194a190ff7005302bf50602d16ed
Signed-off-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-on: http://git-master/r/424329
(cherry picked from commit 10e648c2e2f9760c97ce55a1091d9e7097d2504d)
Reviewed-on: http://git-master/r/448530
Tested-by: Winnie Hsu <whsu@nvidia.com>
drivers/video/tegra/nvmap/nvmap_dmabuf.c

index 518100b95cce43ae680116dc7fb9fca653d2038c..162e4346454c0517cd903a9a8b1e75cae2369b3d 100644 (file)
@@ -429,6 +429,8 @@ static void nvmap_dmabuf_release(struct dma_buf *dmabuf)
                                   info->handle->owner->name : "unknown",
                                   info->handle,
                                   dmabuf);
+       BUG_ON(dmabuf != info->handle->dmabuf);
+       info->handle->dmabuf = NULL;
 
        mutex_lock(&info->maps_lock);
        while (!list_empty(&info->maps)) {
@@ -440,8 +442,7 @@ static void nvmap_dmabuf_release(struct dma_buf *dmabuf)
        }
        mutex_unlock(&info->maps_lock);
 
-       dma_buf_detach(info->handle->dmabuf, info->handle->attachment);
-       info->handle->dmabuf = NULL;
+       dma_buf_detach(dmabuf, info->handle->attachment);
        nvmap_handle_put(info->handle);
        kfree(info);
 }