egl/wayland: add a NULL guard for the authenticate callback

On some platforms, the authenticate callback may be NULL, e.g. on
surfaceless. If a client tries to send a wl_drm.authenticate request
the handler tries to dereference the NULL pointer.

This can be reproduced with libva which unconditionally tries to use
wl_drm.authenticate even with render nodes [1]. Run a compositor with
a surfaceless context, then try to start e.g. mpv to trigger the
segfault.

[1]: https://github.com/intel/libva/pull/476

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7992>
This commit is contained in:
Simon Ser 2020-12-08 19:17:37 +01:00 committed by Marge Bot
parent a709d99bfd
commit c37d8ae82b
1 changed files with 2 additions and 1 deletions

View File

@ -180,7 +180,8 @@ drm_authenticate(struct wl_client *client,
{
struct wl_drm *drm = wl_resource_get_user_data(resource);
if (drm->callbacks.authenticate(drm->user_data, id) < 0)
if (!drm->callbacks.authenticate ||
drm->callbacks.authenticate(drm->user_data, id) < 0)
wl_resource_post_error(resource,
WL_DRM_ERROR_AUTHENTICATE_FAIL,
"authenticate failed");