summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2016-11-09 10:21:03 -0800
committerEmil Velikov <emil.l.velikov@gmail.com>2016-11-23 13:58:45 +0000
commita4b67f664e6a52898e681b35ca769e1fd206a4d1 (patch)
treef7c8b502076a1c2112ba8fe2a43af061717b1e93
parent0a2c318d9c48bce0d5865be69c008631a5f98e87 (diff)
downloadexternal_mesa3d-a4b67f664e6a52898e681b35ca769e1fd206a4d1.zip
external_mesa3d-a4b67f664e6a52898e681b35ca769e1fd206a4d1.tar.gz
external_mesa3d-a4b67f664e6a52898e681b35ca769e1fd206a4d1.tar.bz2
vulkan/wsi/wayland: Clean up some error handling paths
This gets rid of all the memory leaks reported by the WSI CTS tests. Signed-off-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Dave Airlie <airlied@redhat.com> Cc: "13.0" <mesa-stable@lists.freedesktop.org> (cherry picked from commit 302f641d14f5c4d1560b6a0170803e21bd4bb976)
-rw-r--r--src/vulkan/wsi/wsi_common_wayland.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c
index 79f7e96..a61b74d 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -322,6 +322,8 @@ wsi_wl_get_display(struct wsi_device *wsi_device,
pthread_mutex_unlock(&wsi->mutex);
struct wsi_wl_display *display = wsi_wl_display_create(wsi, wl_display);
+ if (!display)
+ return NULL;
pthread_mutex_lock(&wsi->mutex);
@@ -398,6 +400,8 @@ wsi_wl_surface_get_formats(VkIcdSurfaceBase *icd_surface,
VkIcdSurfaceWayland *surface = (VkIcdSurfaceWayland *)icd_surface;
struct wsi_wl_display *display =
wsi_wl_get_display(wsi_device, surface->display);
+ if (!display)
+ return VK_ERROR_OUT_OF_HOST_MEMORY;
uint32_t count = u_vector_length(&display->formats);
@@ -827,6 +831,10 @@ wsi_wl_finish_wsi(struct wsi_device *wsi_device,
(struct wsi_wayland *)wsi_device->wsi[VK_ICD_WSI_PLATFORM_WAYLAND];
if (wsi) {
+ struct hash_entry *entry;
+ hash_table_foreach(wsi->displays, entry)
+ wsi_wl_display_destroy(wsi, entry->data);
+
_mesa_hash_table_destroy(wsi->displays, NULL);
pthread_mutex_destroy(&wsi->mutex);