vulkan: Fix Wayland uninitialised registry
authorDaniel Stone <daniels@collabora.com>
Fri, 28 Apr 2017 14:49:47 +0000 (16:49 +0200)
committerDaniel Stone <daniels@collabora.com>
Fri, 19 May 2017 08:34:52 +0000 (09:34 +0100)
Untangle the exit cleanup paths so we don't try to use the registry
variable before it's been initialised.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: mesa-stable@lists.freedesktop.org
src/vulkan/wsi/wsi_common_wayland.c

index cb6dd7968f312597fab034c96dd83f29a145682e..a1904c02b9e191b7d89a1d4d94b80913bdd146cf 100644 (file)
@@ -273,7 +273,7 @@ wsi_wl_display_create(struct wsi_wayland *wsi, struct wl_display *wl_display)
 
    struct wl_registry *registry = wl_display_get_registry(wl_display);
    if (!registry)
-      return NULL;
+      goto fail;
 
    wl_registry_add_listener(registry, &registry_listener, display);
 
@@ -281,24 +281,25 @@ wsi_wl_display_create(struct wsi_wayland *wsi, struct wl_display *wl_display)
    wl_display_roundtrip(wl_display);
 
    if (!display->drm)
-      goto fail;
+      goto fail_registry;
 
    /* Round-rip to get wl_drm formats and capabilities */
    wl_display_roundtrip(wl_display);
 
    /* We need prime support */
    if (!(display->capabilities & WL_DRM_CAPABILITY_PRIME))
-      goto fail;
+      goto fail_registry;
 
    /* We don't need this anymore */
    wl_registry_destroy(registry);
 
    return display;
 
-fail:
+fail_registry:
    if (registry)
       wl_registry_destroy(registry);
 
+fail:
    wsi_wl_display_destroy(wsi, display);
    return NULL;
 }