summaryrefslogtreecommitdiff
path: root/src/egl
diff options
context:
space:
mode:
authorJosé Expósito <jose.exposito89@gmail.com>2021-11-28 17:57:25 +0100
committerMarge Bot <emma+marge@anholt.net>2022-03-07 08:26:01 +0000
commit43258dc802e07894ae3edd9ea98337a9dc7a0e8e (patch)
tree72e99cbdc492f72da4c9f184c78a81b536c12d87 /src/egl
parenta0bfd65d0fd3c2b0e0cada77aa26b5a52bef3b85 (diff)
egl/wayland: fix crash in dri2_initialize_wayland_drm
When "dri2_wl_formats_init" fails in "dri2_initialize_wayland_drm", the "dri2_display_destroy" function is called for clean up. However, the "dri2_egl_display" was not associated with the display in its "DriverData" field yet. The following cast in "dri2_display_destroy": struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); Expands to: _EGL_DRIVER_TYPECAST(drvname ## _display, _EGLDisplay, obj->DriverData) Crashing. Addresses-Coverity-ID: 1494541 ("Resource leak") Signed-off-by: José Expósito <jose.exposito89@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13972>
Diffstat (limited to 'src/egl')
-rw-r--r--src/egl/drivers/dri2/platform_wayland.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index 1c2d9540da9..242cf5891d9 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -2045,11 +2045,12 @@ dri2_initialize_wayland_drm(_EGLDisplay *disp)
if (!dri2_dpy)
return _eglError(EGL_BAD_ALLOC, "eglInitialize");
+ dri2_dpy->fd = -1;
+ disp->DriverData = (void *) dri2_dpy;
+
if (dri2_wl_formats_init(&dri2_dpy->formats) < 0)
goto cleanup;
- dri2_dpy->fd = -1;
- disp->DriverData = (void *) dri2_dpy;
if (disp->PlatformDisplay == NULL) {
dri2_dpy->wl_dpy = wl_display_connect(NULL);
if (dri2_dpy->wl_dpy == NULL)