Mesa (main): tu/kgsl: Fix file descriptor double close

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jun 24 18:49:11 UTC 2021


Module: Mesa
Branch: main
Commit: 8d0d2e82e7506d15a98b7889dd1478d472fdef0b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8d0d2e82e7506d15a98b7889dd1478d472fdef0b

Author: Alexey Nurmukhametov <alex at nurmukhametov.ru>
Date:   Wed Jun 23 19:38:06 2021 +0300

tu/kgsl: Fix file descriptor double close

tu_kgsl.c: tu_enumerate_devices closed fd previously closed by
tu_physical_device_init function.

Move out the fd closing from tu_physical_device_init function because
they do not belong to it.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11561>

---

 src/freedreno/vulkan/tu_device.c | 17 +++++------------
 src/freedreno/vulkan/tu_drm.c    |  4 +++-
 2 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c
index 5d4ae2bb192..abf68b94430 100644
--- a/src/freedreno/vulkan/tu_device.c
+++ b/src/freedreno/vulkan/tu_device.c
@@ -215,12 +215,12 @@ tu_physical_device_init(struct tu_physical_device *device,
    default:
       result = vk_startup_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
                                  "device %s is unsupported", device->name);
-      goto fail_fds;
+      return result;
    }
    if (tu_device_get_cache_uuid(device->gpu_id, device->cache_uuid)) {
       result = vk_startup_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
                                  "cannot generate UUID");
-      goto fail_fds;
+      return result;
    }
 
    /* The gpu id is already embedded in the uuid so we just pass "tu"
@@ -246,25 +246,18 @@ tu_physical_device_init(struct tu_physical_device *device,
                                     &supported_extensions,
                                     &dispatch_table);
    if (result != VK_SUCCESS)
-      goto fail_fds;
+      return result;
 
 #if TU_HAS_SURFACE
    result = tu_wsi_init(device);
    if (result != VK_SUCCESS) {
       vk_startup_errorf(instance, result, "WSI init failure");
-      goto fail_vk_pd_init;
+      vk_physical_device_finish(&device->vk);
+      return result;
    }
 #endif
 
    return VK_SUCCESS;
-
-fail_vk_pd_init:
-   vk_physical_device_finish(&device->vk);
-fail_fds:
-   close(device->local_fd);
-   if (device->master_fd != -1)
-      close(device->master_fd);
-   return result;
 }
 
 static void
diff --git a/src/freedreno/vulkan/tu_drm.c b/src/freedreno/vulkan/tu_drm.c
index 0c6454e796f..f4c0e5921ff 100644
--- a/src/freedreno/vulkan/tu_drm.c
+++ b/src/freedreno/vulkan/tu_drm.c
@@ -467,7 +467,9 @@ tu_drm_device_init(struct tu_physical_device *device,
    device->heap.used = 0u;
    device->heap.flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT;
 
-   return tu_physical_device_init(device, instance);
+   result = tu_physical_device_init(device, instance);
+   if (result == VK_SUCCESS)
+       return result;
 
 fail:
    close(fd);



More information about the mesa-commit mailing list