xwayland: check queued DRM lease allocation

registry_global() queues DRM lease devices before the root window is
available and initializes the queued entry immediately after malloc().
Return early on allocation failure to avoid dereferencing a NULL
pointer.

Signed-off-by: Mikhail Dmitrichenko <m.dmitrichenko222@gmail.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2217>
This commit is contained in:
Mikhail Dmitrichenko 2026-05-18 14:32:49 +03:00 committed by Marge Bot
parent 731cb81ba1
commit 872ece04f9

View file

@ -540,6 +540,10 @@ registry_global(void *data, struct wl_registry *registry, uint32_t id,
else if (strcmp(interface, wp_drm_lease_device_v1_interface.name) == 0) {
if (xwl_screen->screen->root == NULL) {
struct xwl_queued_drm_lease_device *queued = malloc(sizeof(struct xwl_queued_drm_lease_device));
if (!queued) {
ErrorF("%s: ENOMEM\n", __func__);
return;
}
queued->id = id;
xorg_list_append(&queued->link, &xwl_screen->queued_drm_lease_devices);
} else {