From 8116a32df613df4433aa1b128c58bf2c18479824 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Mon, 11 Jun 2012 08:52:24 -0500 Subject: omap: clarify dmabuf file descriptor ownership Signed-off-by: Rob Clark --- omap/omap_drm.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'omap') diff --git a/omap/omap_drm.c b/omap/omap_drm.c index 336da115..464dea9c 100644 --- a/omap/omap_drm.c +++ b/omap/omap_drm.c @@ -35,6 +35,7 @@ #include #include #include +#include #include @@ -228,6 +229,10 @@ void omap_bo_del(struct omap_bo *bo) munmap(bo->map, bo->size); } + if (bo->fd) { + close(bo->fd); + } + if (bo->handle) { struct drm_gem_close req = { .handle = bo->handle, @@ -266,6 +271,9 @@ uint32_t omap_bo_handle(struct omap_bo *bo) return bo->handle; } +/* caller owns the dmabuf fd that is returned and is responsible + * to close() it when done + */ int omap_bo_dmabuf(struct omap_bo *bo) { if (!bo->fd) { @@ -282,7 +290,7 @@ int omap_bo_dmabuf(struct omap_bo *bo) bo->fd = req.fd; } - return bo->fd; + return dup(bo->fd); } uint32_t omap_bo_size(struct omap_bo *bo) -- cgit v1.2.3