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>
This commit is contained in:
Alexey Nurmukhametov 2021-06-23 19:38:06 +03:00 committed by Marge Bot
parent a426d7c264
commit 8d0d2e82e7
2 changed files with 8 additions and 13 deletions

View File

@ -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

View File

@ -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);