drm_hwcomposer: Add refcount for GEM handle
The linux kernel doesn't provide reference counting for the handle
returned by FD_TO_HANDLE ioctl. It means that if the same Gralloc buffer
is imported twice, the first GEM_CLOSE will destroy the handle even if it
is still in use by another import.
Remedy this issue by doing the reference counting directly in the DRM
generic platform support: ImportHandle() will increase the reference,
while ReleaseHandle() will decrease and close it, if necessary.
Signed-off-by: Vincent Donnefort <vincent.donnefort@arm.com>
diff --git a/platform/platformmeson.cpp b/platform/platformmeson.cpp
index 5184972..7b7a1f1 100644
--- a/platform/platformmeson.cpp
+++ b/platform/platformmeson.cpp
@@ -123,6 +123,8 @@
return ret;
}
+ ImportHandle(gem_handle);
+
return ret;
}