Module: Mesa Branch: main Commit: 4a178cf858ddb98cbff927f5d4330a435bc759b8 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4a178cf858ddb98cbff927f5d4330a435bc759b8
Author: Boris Brezillon <[email protected]> Date: Mon Sep 6 16:12:08 2021 +0200 panvk: Close the panfrost device in the panvk_physical_device_init() error path Otherwise some resources stay around. Signed-off-by: Boris Brezillon <[email protected]> Reviewed-by: Tomeu Vizoso <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12762> --- src/panfrost/vulkan/panvk_device.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/panfrost/vulkan/panvk_device.c b/src/panfrost/vulkan/panvk_device.c index 3c6624010d3..2eb8fa3100b 100644 --- a/src/panfrost/vulkan/panvk_device.c +++ b/src/panfrost/vulkan/panvk_device.c @@ -303,6 +303,7 @@ panvk_physical_device_init(struct panvk_physical_device *device, device->master_fd = master_fd; device->pdev.debug = PAN_DBG_TRACE; panfrost_open_device(NULL, fd, &device->pdev); + fd = -1; if (device->pdev.quirks & MIDGARD_SFBD) { result = vk_errorf(instance, VK_ERROR_INCOMPATIBLE_DRIVER, @@ -319,7 +320,7 @@ panvk_physical_device_init(struct panvk_physical_device *device, if (panvk_device_get_cache_uuid(device->pdev.gpu_id, device->cache_uuid)) { result = vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED, "cannot generate UUID"); - goto fail; + goto fail_close_device; } fprintf(stderr, "WARNING: panvk is not a conformant vulkan implementation, " @@ -331,13 +332,16 @@ panvk_physical_device_init(struct panvk_physical_device *device, result = panvk_wsi_init(device); if (result != VK_SUCCESS) { vk_error(instance, result); - goto fail; + goto fail_close_device; } return VK_SUCCESS; +fail_close_device: + panfrost_close_device(&device->pdev); fail: - close(fd); + if (fd != -1) + close(fd); if (master_fd != -1) close(master_fd); return result;
