radv: replace all dup() with os_dupfd_cloexec()
authorEric Engestrom <eric@engestrom.ch>
Fri, 5 Jun 2020 08:22:04 +0000 (10:22 +0200)
committerMarge Bot <eric+marge@anholt.net>
Thu, 18 Jun 2020 02:09:56 +0000 (02:09 +0000)
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5369>

src/amd/vulkan/radv_android.c

index a9f39ec9e0276e2f25d92164df7a2dd874752b4a..78c0ab48ea7b386b8acd8e6db58f7663eb0e30e3 100644 (file)
@@ -35,6 +35,8 @@
 #endif
 #endif
 
+#include "util/os_file.h"
+
 #include "radv_private.h"
 #include "vk_util.h"
 
@@ -137,7 +139,7 @@ radv_image_from_gralloc(VkDevice device_h,
        const VkImportMemoryFdInfoKHR import_info = {
                .sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR,
                .handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT,
-               .fd = dup(dma_buf),
+               .fd = os_dupfd_cloexec(dma_buf),
        };
 
        /* Find the first VRAM memory type, or GART for PRIME images. */
@@ -389,7 +391,7 @@ radv_AcquireImageANDROID(
        VkResult semaphore_result = VK_SUCCESS, fence_result = VK_SUCCESS;
 
        if (semaphore != VK_NULL_HANDLE) {
-               int semaphore_fd = nativeFenceFd >= 0 ? dup(nativeFenceFd) : nativeFenceFd;
+               int semaphore_fd = nativeFenceFd >= 0 ? os_dupfd_cloexec(nativeFenceFd) : nativeFenceFd;
                semaphore_result = radv_ImportSemaphoreFdKHR(device,
                                                             &(VkImportSemaphoreFdInfoKHR) {
                                                                 .sType = VK_STRUCTURE_TYPE_IMPORT_SEMAPHORE_FD_INFO_KHR,
@@ -400,7 +402,7 @@ radv_AcquireImageANDROID(
        }
 
        if (fence != VK_NULL_HANDLE) {
-               int fence_fd = nativeFenceFd >= 0 ? dup(nativeFenceFd) : nativeFenceFd;
+               int fence_fd = nativeFenceFd >= 0 ? os_dupfd_cloexec(nativeFenceFd) : nativeFenceFd;
                fence_result = radv_ImportFenceFdKHR(device,
                                                     &(VkImportFenceFdInfoKHR) {
                                                         .sType = VK_STRUCTURE_TYPE_IMPORT_FENCE_FD_INFO_KHR,