diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c index 3f95c03d581..154d1278c7a 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; }