Mesa (main): panvk: Close the panfrost device in the panvk_physical_device_init() error path
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Sep 10 10:04:57 UTC 2021
Module: Mesa
Branch: main
Commit: 4a178cf858ddb98cbff927f5d4330a435bc759b8
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4a178cf858ddb98cbff927f5d4330a435bc759b8
Author: Boris Brezillon <boris.brezillon at collabora.com>
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 <boris.brezillon at collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso at collabora.com>
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;
More information about the mesa-commit
mailing list