zink: Fix crash on zink_create_screen error path

The `zink_internal_create_screen()` function can fail before
`screen->loader_lib` and/or `screen->instance` are initialized.
The `zink_destroy_screen()` doesn't check those cases and crashes.

The error was found by Fedora's CI. The back trace is available at [1].

[1] https://bodhi.fedoraproject.org/updates/FEDORA-2023-c39f82c465

Fixes: 0c2045553f ("zink: use screen destructor for creation fails")
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: José Expósito <jexposit@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26029>
This commit is contained in:
José Expósito 2023-11-03 14:15:06 +01:00 committed by Marge Bot
parent 5a85f67fa4
commit 8a635e516e

View file

@ -1520,10 +1520,14 @@ zink_destroy_screen(struct pipe_screen *pscreen)
if (screen->dev)
VKSCR(DestroyDevice)(screen->dev, NULL);
VKSCR(DestroyInstance)(screen->instance, NULL);
if (screen->instance)
VKSCR(DestroyInstance)(screen->instance, NULL);
util_idalloc_mt_fini(&screen->buffer_ids);
util_dl_close(screen->loader_lib);
if (screen->loader_lib)
util_dl_close(screen->loader_lib);
if (screen->drm_fd != -1)
close(screen->drm_fd);