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/platformimagination.cpp b/platform/platformimagination.cpp
index 565e6ee..5e0335c 100644
--- a/platform/platformimagination.cpp
+++ b/platform/platformimagination.cpp
@@ -69,6 +69,8 @@
return ret;
}
+ ImportHandle(gem_handle);
+
return 0;
}