xserver/hw/xwayland
Olivier Fourdan d346a6dec0 xwayland: Avoid NULL pointer dereference in damage_report()
Commit 34934c37d6 restored calling register_damage() in
xwl_realize_window() before ensure_surface_for_window().

However if register_damage() succeeds and ensure_surface_for_window()
returns NULL, it would exit without "unregistering" the damage hook.

The X11 window, however, may still get damages reports, in which case
xwl_window_from_window() would return NULL, causing a NULL pointer
dereference in damage_report().

To avoid the issue, make sure we unregister the damage report if
ensure_surface_for_window() has failed, and add an early exit in
damage_report() if xwl_window is NULL.

v2: unregister_damage() unconditionally if ensure_surface_for_window()
    failed (Michel Dänzer)

Fixes: commit 34934c37d6 ("revert: register damage before ensure_surface_for_window")
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/work_items/1886
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
(cherry picked from commit 36f53145e4)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2191>
2026-04-24 09:44:33 +02:00
..
desktop xwayland: Use "-decorate" if available 2024-03-18 23:19:59 +00:00
man xwayland: Update the global screen scale 2024-03-20 09:05:36 +01:00
.gitignore xwayland: Add wp_viewport wayland extension support 2019-10-12 12:19:14 +02:00
drm.xml wayland: Sync drm.xml with Mesa 2017-07-05 10:13:04 -04:00
meson.build pkgconfig files: Add URL 2025-04-08 10:05:31 +02:00
xwayland-cursor.c xwayland: Do not keep the cursor's pixmap around 2025-02-04 09:20:54 +01:00
xwayland-cursor.h xwayland: Add xwl_cursor_clear_frame_cb() 2021-10-25 12:05:42 +00:00
xwayland-cvt.c xwayland: Keep the CVT timings for non-standard modes 2023-05-15 10:33:21 +02:00
xwayland-cvt.h xwayland: Move Xwayland CVT declaration 2019-12-20 16:19:01 +01:00
xwayland-dmabuf.c xwayland/window-buffers: optionally force disposal 2024-07-04 08:36:40 +00:00
xwayland-dmabuf.h xwayland: Move dmabuf code to its own source file 2024-03-14 15:00:46 +01:00
xwayland-drm-lease.c xwayland: Do not remove output on withdraw if leased 2024-05-02 10:17:42 +02:00
xwayland-drm-lease.h Xwayland: implement drm-lease-v1 2021-12-07 10:02:29 +00:00
xwayland-glamor-gbm.c xwayland/glamor: Disable GLAMOR after GBM cleanup 2025-02-04 18:14:06 +01:00
xwayland-glamor-gbm.h xwayland/glamor/gbm: Copy explicit sync code to GLAMOR/GBM 2024-07-04 08:36:40 +00:00
xwayland-glamor-xv.c xwayland: Cleanup and remove xwayland.h 2019-12-20 16:19:01 +01:00
xwayland-glamor.c xwayland/glamor/gbm: Don't close fence_fd after xwl_glamor_wait_fence 2025-02-04 09:17:46 +01:00
xwayland-glamor.h xwayland: Pass xwl_window to xwl_glamor_dri3_syncobj_passthrough 2024-04-10 08:55:08 +00:00
xwayland-input.c xwayland: Do not use pointer crossing count for slave devices 2026-04-21 10:06:21 +02:00
xwayland-input.h xwayland: wrong expecting_event 2026-04-09 08:59:09 +00:00
xwayland-output.c xwayland: Fix search of duplicate lease names 2025-10-21 08:56:39 +02:00
xwayland-output.h xwayland: Do not remove output on withdraw if leased 2024-05-02 10:17:42 +02:00
xwayland-pixmap.c xwayland: Add xwl_pixmap_get_wl_buffer helper 2024-01-22 14:14:05 +00:00
xwayland-pixmap.h xwayland: Replace window pixmap as needed for drawing operation 2024-03-06 17:12:54 +01:00
xwayland-present.c xwayland/present: Check allow_commits in xwl_present_flip 2025-02-04 09:19:14 +01:00
xwayland-present.h xwayland/present: Add xwl_present_maybe_(un)redirect_window 2024-04-10 08:55:08 +00:00
xwayland-screen.c xwayland: fix builds with xace disabled 2026-04-09 08:59:08 +00:00
xwayland-screen.h xwayland: Add heuristic for WM windows based on reparenting 2025-10-21 08:56:39 +02:00
xwayland-shm.c os: move os_move_fd() out of public API 2024-03-09 17:12:46 +00:00
xwayland-shm.h xwayland: Move SHM declarations to their own header 2019-12-20 16:19:01 +01:00
xwayland-types.h xwayland/window-buffers: Promote xwl_window_buffer 2024-07-04 08:36:40 +00:00
xwayland-vidmode.c xwayland: add a fixed geometry size for rootful 2022-06-30 17:52:22 +02:00
xwayland-vidmode.h xwayland: Move Xwayland vidmode declaration 2019-12-20 16:19:01 +01:00
xwayland-window-buffers.c xwayland: Do not include sys/eventfd.h without DRI3 2024-08-06 10:00:59 +02:00
xwayland-window-buffers.h xwayland/window-buffers: optionally force disposal 2024-07-04 08:36:40 +00:00
xwayland-window.c xwayland: Avoid NULL pointer dereference in damage_report() 2026-04-24 09:44:33 +02:00
xwayland-window.h xwayland: Add heuristic for WM windows based on reparenting 2025-10-21 08:56:39 +02:00
xwayland-xtest.c xwayland: prevent potential null pointer dereference 2025-02-04 09:16:51 +01:00
xwayland-xtest.h xwayland: Fallback to plain XTEST if EI does not work 2023-06-26 13:19:19 +02:00
xwayland.c xwayland: Update the global screen scale 2024-03-20 09:05:36 +01:00