From 8bfcc61d2587b9f13192653ebad24e01d2c95d2c Mon Sep 17 00:00:00 2001 From: Krishna Reddy Date: Tue, 17 Jun 2014 12:30:16 -0700 Subject: [PATCH] video: tegra: nvmap: set handle dmabuf to NULL early This can allow catching handle dmabuf usage during its free. Bug 1529015 Change-Id: Ie20c7b860ca5194a190ff7005302bf50602d16ed Signed-off-by: Krishna Reddy Reviewed-on: http://git-master/r/424329 (cherry picked from commit 10e648c2e2f9760c97ce55a1091d9e7097d2504d) Reviewed-on: http://git-master/r/448530 Tested-by: Winnie Hsu --- drivers/video/tegra/nvmap/nvmap_dmabuf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/video/tegra/nvmap/nvmap_dmabuf.c b/drivers/video/tegra/nvmap/nvmap_dmabuf.c index 518100b95cc..162e4346454 100644 --- a/drivers/video/tegra/nvmap/nvmap_dmabuf.c +++ b/drivers/video/tegra/nvmap/nvmap_dmabuf.c @@ -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); } -- 2.39.2