From f4eb13dc55446794c4449386fa7f838ed061ce19 Mon Sep 17 00:00:00 2001 From: Erik Kurzinger Date: Mon, 3 May 2021 08:18:03 -0400 Subject: [PATCH] vulkan/device_select: avoid segfault on Wayland if wl_drm is unavailable On Wayland, if the wl_drm interface is not available, for example if the compositor is using the proprietary NVIDIA driver along with their egl-wayland library, the device_select layer will fail to initialize. However, the failure path will unconditionally call wl_drm_destroy even though info.wl_drm would be NULL in that case. This can cause a segfault in libwayland-client.so. To fix this, check if info.wl_drm is NULL before calling wl_drm_destroy. This way, initialization will fail gracefully even if that interface is not present. Signed-off-by: Erik Kurzinger Reviewed-by: Lionel Landwerlin Reviewed-by: Eric Engestrom Part-of: --- src/vulkan/device-select-layer/device_select_wayland.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/vulkan/device-select-layer/device_select_wayland.c b/src/vulkan/device-select-layer/device_select_wayland.c index 73db275a55a..161310b0292 100644 --- a/src/vulkan/device-select-layer/device_select_wayland.c +++ b/src/vulkan/device-select-layer/device_select_wayland.c @@ -139,7 +139,8 @@ int device_select_find_wayland_pci_default(struct device_pci_info *devices, uint } } - wl_drm_destroy(info.wl_drm); + if (info.wl_drm) + wl_drm_destroy(info.wl_drm); wl_registry_destroy(registry); wl_display_disconnect(display); out: