[PATCH] drm: cma: fix refcounting on the dmabuf import error path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>From drm gem CMA helper, it wasn't fixed dma_buf refcount problem fixed
by commit 011c228. This patch solves it.

Signed-off-by: Joonyoung Shim <jy0922.shim@xxxxxxxxxxx>
---
 drivers/gpu/drm/drm_gem_cma_helper.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c
index ce06397..3f3a12b 100644
--- a/drivers/gpu/drm/drm_gem_cma_helper.c
+++ b/drivers/gpu/drm/drm_gem_cma_helper.c
@@ -554,7 +554,6 @@ struct drm_gem_object *drm_gem_cma_dmabuf_import(struct drm_device *drm,
 			 * refcount on gem itself instead of f_count of dmabuf.
 			 */
 			drm_gem_object_reference(obj);
-			dma_buf_put(dma_buf);
 			return obj;
 		}
 	}
@@ -573,6 +572,8 @@ struct drm_gem_object *drm_gem_cma_dmabuf_import(struct drm_device *drm,
 		goto error_gem_free;
 	}
 
+	get_dma_buf(dma_buf);
+
 	sgt = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL);
 	if (IS_ERR_OR_NULL(sgt)) {
 		ret = sgt ? PTR_ERR(sgt) : -ENOMEM;
@@ -597,6 +598,7 @@ error_buf_unmap:
 	dma_buf_unmap_attachment(attach, sgt, DMA_BIDIRECTIONAL);
 error_buf_detach:
 	dma_buf_detach(dma_buf, attach);
+	dma_buf_put(dma_buf);
 error_gem_free:
 	drm_gem_cma_free_object(&cma_obj->base);
 	return ERR_PTR(ret);
-- 
1.8.1.2

--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]