Revert "wayland-drm: constify the callbacks struct"
authorDaniel Stone <daniels@collabora.com>
Fri, 22 Sep 2017 22:40:59 +0000 (15:40 -0700)
committerDaniel Stone <daniels@collabora.com>
Tue, 26 Sep 2017 20:48:17 +0000 (21:48 +0100)
The wayland-drm callback struct is referenced, rather than duplicated,
inside wayland-drm. Constifying this struct involved moving it on to the
stack; as a result, starting any EGL client on Wayland called into
random stack memory, and killed the compositor.

This reverts commit 1d0be5b3fe548ee33d4520092f583c76d42510a6 and
39d539e321c6c97433a15660c9d9a20ad8657ff0.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Cc: Emil Velikov <emil.velikov@collabora.com>
Cc: Krzysztof Sobiecki <sobkas@gmail.com>
Fixes: 1d0be5b3fe54 ("wayland-drm: constify the callbacks struct")
src/egl/drivers/dri2/egl_dri2.c
src/egl/wayland/wayland-drm/wayland-drm.c
src/egl/wayland/wayland-drm/wayland-drm.h

index 0dce2246c1592772d78412184de56859dfd48419..8f589926963ed1b317b1a45609839029c16797f1 100644 (file)
@@ -2718,16 +2718,17 @@ dri2_wl_release_buffer(void *user_data, struct wl_drm_buffer *buffer)
    dri2_dpy->image->destroyImage(buffer->driver_buffer);
 }
 
+static struct wayland_drm_callbacks wl_drm_callbacks = {
+        .authenticate = NULL,
+        .reference_buffer = dri2_wl_reference_buffer,
+        .release_buffer = dri2_wl_release_buffer
+};
+
 static EGLBoolean
 dri2_bind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp,
                              struct wl_display *wl_dpy)
 {
    struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
-   const struct wayland_drm_callbacks wl_drm_callbacks = {
-      .authenticate = (int(*)(void *, uint32_t)) dri2_dpy->vtbl->authenticate,
-      .reference_buffer = dri2_wl_reference_buffer,
-      .release_buffer = dri2_wl_release_buffer
-   };
    int flags = 0;
    uint64_t cap;
 
@@ -2736,6 +2737,9 @@ dri2_bind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp,
    if (dri2_dpy->wl_server_drm)
            return EGL_FALSE;
 
+   wl_drm_callbacks.authenticate =
+      (int(*)(void *, uint32_t)) dri2_dpy->vtbl->authenticate;
+
    if (drmGetCap(dri2_dpy->fd, DRM_CAP_PRIME, &cap) == 0 &&
        cap == (DRM_PRIME_CAP_IMPORT | DRM_PRIME_CAP_EXPORT) &&
        dri2_dpy->image->base.version >= 7 &&
index 5c17b4386b55670c55dd6705c6f15e369cd8c210..2e256aea6d5d453396afa1f55c0eb12fbedc38b7 100644 (file)
@@ -47,7 +47,7 @@ struct wl_drm {
        char *device_name;
         uint32_t flags;
 
-       const struct wayland_drm_callbacks *callbacks;
+       struct wayland_drm_callbacks *callbacks;
 
         struct wl_buffer_interface buffer_interface;
 };
@@ -259,7 +259,7 @@ wayland_drm_buffer_get(struct wl_drm *drm, struct wl_resource *resource)
 
 struct wl_drm *
 wayland_drm_init(struct wl_display *display, char *device_name,
-                 const struct wayland_drm_callbacks *callbacks, void *user_data,
+                 struct wayland_drm_callbacks *callbacks, void *user_data,
                  uint32_t flags)
 {
        struct wl_drm *drm;
index 111383ff1d687419e47fd660590873cb0b42ac29..77e8d27304245ad1ae2c71fb651f892e08554f0e 100644 (file)
@@ -34,7 +34,7 @@ wayland_drm_buffer_get(struct wl_drm *drm, struct wl_resource *resource);
 
 struct wl_drm *
 wayland_drm_init(struct wl_display *display, char *device_name,
-                const struct wayland_drm_callbacks *callbacks, void *user_data,
+                struct wayland_drm_callbacks *callbacks, void *user_data,
                  uint32_t flags);
 
 void