Mesa (staging/21.1): vulkan/device_select: avoid segfault on Wayland if wl_drm is unavailable

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jun 2 17:52:19 UTC 2021


Module: Mesa
Branch: staging/21.1
Commit: a6e006f1bdf03da04d889d8fea9514ceb127e565
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a6e006f1bdf03da04d889d8fea9514ceb127e565

Author: Erik Kurzinger <ekurzinger at nvidia.com>
Date:   Mon May  3 08:18:03 2021 -0400

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 <ekurzinger at nvidia.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Reviewed-by: Eric Engestrom <eric at engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10598>

(cherry picked from commit f4eb13dc55446794c4449386fa7f838ed061ce19)

---

 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:



More information about the mesa-commit mailing list