[mutter] renderer-native: Don't leak DMA buffer CoglFramebuffer



commit c823b5ddba18d30e1fdb74d6764cd40637dc4054
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Tue Jun 2 18:34:57 2020 +0200

    renderer-native: Don't leak DMA buffer CoglFramebuffer
    
    When we created the DMA buffer backed CoglFramebuffer, we handed it over
    to CoglDmaBufHandle which took its own reference. What we failed to do
    was to release our own reference to it, effectively leaking it.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1283

 src/backends/native/meta-renderer-native.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
index c4b68f10eb..360bdc0bc4 100644
--- a/src/backends/native/meta-renderer-native.c
+++ b/src/backends/native/meta-renderer-native.c
@@ -2168,6 +2168,7 @@ meta_renderer_native_create_dma_buf (CoglRenderer  *cogl_renderer,
     case META_RENDERER_NATIVE_MODE_GBM:
       {
         CoglFramebuffer *dmabuf_fb;
+        CoglDmaBufHandle *dmabuf_handle;
         struct gbm_bo *new_bo;
         int stride;
         int offset;
@@ -2210,10 +2211,13 @@ meta_renderer_native_create_dma_buf (CoglRenderer  *cogl_renderer,
         if (!dmabuf_fb)
           return NULL;
 
-        return cogl_dma_buf_handle_new (dmabuf_fb, dmabuf_fd,
-                                        width, height, stride, offset, bpp,
-                                        new_bo,
-                                        (GDestroyNotify) gbm_bo_destroy);
+        dmabuf_handle =
+          cogl_dma_buf_handle_new (dmabuf_fb, dmabuf_fd,
+                                   width, height, stride, offset, bpp,
+                                   new_bo,
+                                   (GDestroyNotify) gbm_bo_destroy);
+        cogl_object_unref (dmabuf_fb);
+        return dmabuf_handle;
       }
       break;
 #ifdef HAVE_EGL_DEVICE


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]