From: Mike Blumenkrantz Date: Mon, 27 Feb 2023 17:41:11 +0000 (-0500) Subject: vulkan/wsi: fix crash in failed swapchain creation for wayland X-Git-Tag: upstream/23.3.3~11925 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bf1b4ed54e204e88420a3aa329bf0a41506ebb45;p=platform%2Fupstream%2Fmesa.git 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 Part-of: --- diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c index 3f95c03..154d127 100644 --- a/src/vulkan/wsi/wsi_common_wayland.c +++ b/src/vulkan/wsi/wsi_common_wayland.c @@ -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; }