xserver: Branch 'master' - 3 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Apr 12 07:30:55 UTC 2024


 dri3/dri3_screen.c            |    5 ++++-
 hw/xwayland/xwayland-dmabuf.c |    7 +++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

New commits:
commit 3b6b88c184ddbe41ddab91a543e08fddcef14481
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Thu Apr 11 11:42:51 2024 +0200

    dri3: Free formats in cache_formats_and_modifiers
    
    Fixes leak:
    
    ==15672== 60 bytes in 1 blocks are definitely lost in loss record 3,803 of 8,127
    ==15672==    at 0x4840718: malloc (vg_replace_malloc.c:392)
    ==15672==    by 0x2F2698: XNFreallocarray (alloc.c:55)
    ==15672==    by 0x1ADAA9: xwl_dmabuf_get_formats_for_device (xwayland-dmabuf.c:207)
    ==15672==    by 0x1ADAA9: xwl_glamor_get_formats (xwayland-dmabuf.c:248)
    ==15672==    by 0x303D86: cache_formats_and_modifiers (dri3_screen.c:176)
    ==15672==    by 0x303D86: dri3_get_supported_modifiers (dri3_screen.c:229)
    ==15672==    by 0x30331A: proc_dri3_get_supported_modifiers (dri3_request.c:389)
    ==15672==    by 0x217B6B: Dispatch (dispatch.c:550)
    ==15672==    by 0x21B9A0: dix_main (main.c:276)
    ==15672==    by 0x51086C9: (below main) (libc_start_call_main.h:58)
    
    Fixes: a42992a4cca4 ("dri3: rework format/modifier caching")
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1484>

diff --git a/dri3/dri3_screen.c b/dri3/dri3_screen.c
index 5614a22b3..2430505fb 100644
--- a/dri3/dri3_screen.c
+++ b/dri3/dri3_screen.c
@@ -183,8 +183,10 @@ cache_formats_and_modifiers(ScreenPtr screen)
     }
 
     ds->formats = calloc(num_formats, sizeof(dri3_dmabuf_format_rec));
-    if (!ds->formats)
+    if (!ds->formats) {
+        free(formats);
         return BadAlloc;
+    }
 
     for (i = 0; i < num_formats; i++) {
         dri3_dmabuf_format_ptr iter = &ds->formats[i];
@@ -205,6 +207,7 @@ cache_formats_and_modifiers(ScreenPtr screen)
     ds->num_formats = i;
     ds->formats_cached = TRUE;
 
+    free(formats);
     return Success;
 }
 
commit 4dc7e99840cb9318ceeb3c11e382e46bb282aad5
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Thu Apr 11 11:26:24 2024 +0200

    xwayland: Use drmDevicesEqual in xwl_dmabuf_feedback_tranche_done
    
    xwl_dmabuf_feedback_tranche_target_device always allocates a new
    drmDevice for xwl_feedback->tmp_tranche.drm_dev, so the pointers are
    never equal here.
    
    Fixes: 6f0b9deed668 ("xwayland: use drmDevice to compare DRM devices")
    
    v2:
    * Flip order of checks, so drmDevicesEqual is called only if the
      supports_scanout flags match.
    
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1484>

diff --git a/hw/xwayland/xwayland-dmabuf.c b/hw/xwayland/xwayland-dmabuf.c
index 0c5ed1c86..db7dc44ee 100644
--- a/hw/xwayland/xwayland-dmabuf.c
+++ b/hw/xwayland/xwayland-dmabuf.c
@@ -580,8 +580,8 @@ xwl_dmabuf_feedback_tranche_done(void *data,
      */
     for (int i = 0; i < xwl_feedback->dev_formats_len; i++) {
         tranche = &xwl_feedback->dev_formats[i];
-        if (tranche->drm_dev == xwl_feedback->tmp_tranche.drm_dev &&
-            tranche->supports_scanout == xwl_feedback->tmp_tranche.supports_scanout) {
+        if (tranche->supports_scanout == xwl_feedback->tmp_tranche.supports_scanout &&
+            drmDevicesEqual(tranche->drm_dev, xwl_feedback->tmp_tranche.drm_dev)) {
             appended = TRUE;
 
             /* Add all format/mods to this tranche */
commit 82d3b8ff059dd32656d2829c65e25c09bd0ba424
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Fri Feb 23 18:37:49 2024 +0100

    xwayland: Call drmFreeDevice for dma-buf default feedback
    
    Fixes leaks:
    
    ==13712== 144 bytes in 1 blocks are definitely lost in loss record 4,827 of 7,462
    ==13712==    at 0x48459F3: calloc (vg_replace_malloc.c:1340)
    ==13712==    by 0x49BE94D: drmDeviceAlloc (xf86drm.c:4072)
    ==13712==    by 0x49BFAC9: drmProcessPciDevice (xf86drm.c:4104)
    ==13712==    by 0x49BFAC9: process_device (xf86drm.c:4508)
    ==13712==    by 0x49C35FB: drmGetDeviceFromDevId (xf86drm.c:4670)
    ==13712==    by 0x1AD370: xwl_dmabuf_feedback_main_device (xwayland-dmabuf.c:477)
    ==13712==    by 0x53C03FD: ffi_call_unix64 (unix64.S:104)
    ==13712==    by 0x53BF70C: ffi_call_int (ffi64.c:673)
    ==13712==    by 0x53BFEE2: ffi_call (ffi64.c:710)
    ==13712==    by 0x49AC920: wl_closure_invoke (connection.c:1025)
    ==13712==    by 0x49A8C08: dispatch_event.isra.0 (wayland-client.c:1631)
    ==13712==    by 0x49AA5AB: dispatch_queue (wayland-client.c:1777)
    ==13712==    by 0x49AA5AB: wl_display_dispatch_queue_pending (wayland-client.c:2019)
    ==13712==    by 0x49AAB5E: wl_display_roundtrip_queue (wayland-client.c:1403)
    
    ==13712== 576 bytes in 4 blocks are definitely lost in loss record 6,289 of 7,462
    ==13712==    at 0x48459F3: calloc (vg_replace_malloc.c:1340)
    ==13712==    by 0x49BE94D: drmDeviceAlloc (xf86drm.c:4072)
    ==13712==    by 0x49BFAC9: drmProcessPciDevice (xf86drm.c:4104)
    ==13712==    by 0x49BFAC9: process_device (xf86drm.c:4508)
    ==13712==    by 0x49C35FB: drmGetDeviceFromDevId (xf86drm.c:4670)
    ==13712==    by 0x1AD583: xwl_dmabuf_feedback_main_device (xwayland-dmabuf.c:477)
    ==13712==    by 0x1AD583: xwl_window_dmabuf_feedback_main_device (xwayland-dmabuf.c:691)
    ==13712==    by 0x53C03FD: ffi_call_unix64 (unix64.S:104)
    ==13712==    by 0x53BF70C: ffi_call_int (ffi64.c:673)
    ==13712==    by 0x53BFEE2: ffi_call (ffi64.c:710)
    ==13712==    by 0x49AC920: wl_closure_invoke (connection.c:1025)
    ==13712==    by 0x49A8C08: dispatch_event.isra.0 (wayland-client.c:1631)
    ==13712==    by 0x49AA5AB: dispatch_queue (wayland-client.c:1777)
    ==13712==    by 0x49AA5AB: wl_display_dispatch_queue_pending (wayland-client.c:2019)
    ==13712==    by 0x1A1842: xwl_read_events (xwayland-screen.c:566)
    ==13712==    by 0x1A1842: xwl_read_events (xwayland-screen.c:553)
    
    Fixes: 6f0b9deed668 ("xwayland: use drmDevice to compare DRM devices")
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1484>

diff --git a/hw/xwayland/xwayland-dmabuf.c b/hw/xwayland/xwayland-dmabuf.c
index 8119e1ddb..0c5ed1c86 100644
--- a/hw/xwayland/xwayland-dmabuf.c
+++ b/hw/xwayland/xwayland-dmabuf.c
@@ -74,6 +74,7 @@ xwl_dmabuf_feedback_destroy(struct xwl_dmabuf_feedback *xwl_feedback)
         zwp_linux_dmabuf_feedback_v1_destroy(xwl_feedback->dmabuf_feedback);
 
     xwl_feedback->dmabuf_feedback = NULL;
+    drmFreeDevice(&xwl_feedback->main_dev);
 }
 
 static Bool
@@ -474,6 +475,8 @@ xwl_dmabuf_feedback_main_device(void *data,
     assert(dev->size == sizeof(dev_t));
     memcpy(&devid, dev->data, sizeof(dev_t));
 
+    drmFreeDevice(&xwl_feedback->main_dev);
+
     if (drmGetDeviceFromDevId(devid, 0, &xwl_feedback->main_dev) != 0)
         ErrorF("linux_dmabuf_feedback.main_device: Failed to fetch DRM device\n");
 }


More information about the xorg-commit mailing list