From 9ca2a4e6fc9d059a024ba8da20891ccf79ba659d Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Fri, 5 Jun 2020 10:22:47 +0200 Subject: [PATCH] freedreno: replace all dup() with os_dupfd_cloexec() Signed-off-by: Eric Engestrom Reviewed-by: Kristian H. Kristensen Reviewed-by: Lionel Landwerlin Part-of: --- src/freedreno/drm/freedreno_device.c | 4 +++- src/freedreno/vulkan/tu_android.c | 8 +++++--- src/gallium/drivers/freedreno/freedreno_fence.c | 5 +++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/freedreno/drm/freedreno_device.c b/src/freedreno/drm/freedreno_device.c index be03cca426f..f0dc53b526d 100644 --- a/src/freedreno/drm/freedreno_device.c +++ b/src/freedreno/drm/freedreno_device.c @@ -28,6 +28,8 @@ #include #include +#include "util/os_file.h" + #include "freedreno_drmif.h" #include "freedreno_priv.h" @@ -90,7 +92,7 @@ out: */ struct fd_device * fd_device_new_dup(int fd) { - int dup_fd = dup(fd); + int dup_fd = os_dupfd_cloexec(fd); struct fd_device *dev = fd_device_new(dup_fd); if (dev) dev->closefd = 1; diff --git a/src/freedreno/vulkan/tu_android.c b/src/freedreno/vulkan/tu_android.c index 00a3a577468..d82c8e9125d 100644 --- a/src/freedreno/vulkan/tu_android.c +++ b/src/freedreno/vulkan/tu_android.c @@ -33,6 +33,8 @@ #include "drm-uapi/drm_fourcc.h" +#include "util/os_file.h" + static int tu_hal_open(const struct hw_module_t *mod, const char *id, @@ -154,7 +156,7 @@ tu_image_from_gralloc(VkDevice device_h, .sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR, .pNext = &ded_alloc, .handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT, - .fd = dup(dma_buf), + .fd = os_dupfd_cloexec(dma_buf), }; result = @@ -293,7 +295,7 @@ tu_AcquireImageANDROID(VkDevice device, if (semaphore != VK_NULL_HANDLE) { int semaphore_fd = - nativeFenceFd >= 0 ? dup(nativeFenceFd) : nativeFenceFd; + nativeFenceFd >= 0 ? os_dupfd_cloexec(nativeFenceFd) : nativeFenceFd; semaphore_result = tu_ImportSemaphoreFdKHR( device, &(VkImportSemaphoreFdInfoKHR) { .sType = VK_STRUCTURE_TYPE_IMPORT_SEMAPHORE_FD_INFO_KHR, @@ -304,7 +306,7 @@ tu_AcquireImageANDROID(VkDevice device, } 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 = tu_ImportFenceFdKHR( device, &(VkImportFenceFdInfoKHR) { .sType = VK_STRUCTURE_TYPE_IMPORT_FENCE_FD_INFO_KHR, diff --git a/src/gallium/drivers/freedreno/freedreno_fence.c b/src/gallium/drivers/freedreno/freedreno_fence.c index 71472da704a..59ea1896f45 100644 --- a/src/gallium/drivers/freedreno/freedreno_fence.c +++ b/src/gallium/drivers/freedreno/freedreno_fence.c @@ -26,6 +26,7 @@ #include +#include "util/os_file.h" #include "util/u_inlines.h" #include "freedreno_fence.h" @@ -122,7 +123,7 @@ void fd_create_fence_fd(struct pipe_context *pctx, enum pipe_fd_type type) { assert(type == PIPE_FD_TYPE_NATIVE_SYNC); - *pfence = fence_create(fd_context(pctx), NULL, 0, dup(fd)); + *pfence = fence_create(fd_context(pctx), NULL, 0, os_dupfd_cloexec(fd)); } void fd_fence_server_sync(struct pipe_context *pctx, @@ -146,7 +147,7 @@ int fd_fence_get_fd(struct pipe_screen *pscreen, struct pipe_fence_handle *fence) { fence_flush(fence); - return dup(fence->fence_fd); + return os_dupfd_cloexec(fence->fence_fd); } struct pipe_fence_handle * fd_fence_create(struct fd_batch *batch) -- 2.30.2