vulkan/wsi: fix crash in failed swapchain creation for wayland

this otherwise calls wsi_wl_swapchain_chain_free() before the wsi
pointer has been set

ref #6578

cc: mesa-stable

Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21563>
This commit is contained in:
Mike Blumenkrantz 2023-02-27 12:41:11 -05:00 committed by Marge Bot
parent 41ae2d0725
commit bf1b4ed54e

View file

@ -1495,6 +1495,11 @@ static VkResult wsi_wl_surface_init(struct wsi_wl_surface *wsi_wl_surface,
return VK_SUCCESS;
fail:
if (wsi_wl_surface->surface)
wl_proxy_wrapper_destroy(wsi_wl_surface->surface);
if (wsi_wl_surface->display)
wsi_wl_display_destroy(wsi_wl_surface->display);
return result;
}
@ -1958,10 +1963,8 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
result = wsi_swapchain_init(wsi_device, &chain->base, device,
pCreateInfo, image_params, pAllocator);
if (result != VK_SUCCESS) {
vk_free(pAllocator, chain);
return result;
}
if (result != VK_SUCCESS)
goto fail;
bool alpha = pCreateInfo->compositeAlpha ==
VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR;
@ -2001,8 +2004,10 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
fail_image_init:
wsi_wl_swapchain_images_free(chain);
fail:
wsi_wl_swapchain_chain_free(chain, pAllocator);
fail:
vk_free(pAllocator, chain);
wsi_wl_surface->chain = NULL;
return result;
}