[mutter/gnome-3-36] kms-impl/simple: Fix page_flip_data ref leak on fallback



commit 06b0d41baf47b09a7c019be93710b3de7d218ede
Author: Pekka Paalanen <pekka paalanen collabora com>
Date:   Fri Apr 17 14:50:13 2020 +0300

    kms-impl/simple: Fix page_flip_data ref leak on fallback
    
    If drmModePageFlip() or custom_page_flip_func fails, process_page_flip() was
    forgetting to undo the ref taken for that call. This would leak page_flip_data.
    
    The reference counting works like this:
    - when created, ref count is 1
    - when calling drmModePageFlip, ref count is increased to 2
    - new: if flip failed, ref count is decreased back to 1
    - if calling schedule_retry_page_flip(), it takes a ref internally
    - if calling mode_set_fallback(), it takes a ref internally
    - all return FALSE paths have an explicit unref
    - return TRUE path has an explicit unref
    
    This issue was found by code inspection and while debugging an unrelated issue
    with debug prints sprinkled around. I am not aware of any end-user visible
    issues being fixed by this, as the leak is small and probably very rare.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1209
    (cherry picked from commit 36111270aa23dffdc757cb76f4ca01f3425bfbf2)

 src/backends/native/meta-kms-impl-simple.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/src/backends/native/meta-kms-impl-simple.c b/src/backends/native/meta-kms-impl-simple.c
index e50b1c888..b5c7bb742 100644
--- a/src/backends/native/meta-kms-impl-simple.c
+++ b/src/backends/native/meta-kms-impl-simple.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2018-2019 Red Hat
- * Copyright (C) 2019 DisplayLink (UK) Ltd.
+ * Copyright (C) 2019-2020 DisplayLink (UK) Ltd.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -660,6 +660,9 @@ process_page_flip (MetaKmsImpl    *impl,
                              meta_kms_page_flip_data_ref (page_flip_data));
     }
 
+  if (ret != 0)
+    meta_kms_page_flip_data_unref (page_flip_data);
+
   if (ret == -EBUSY)
     {
       CachedModeSet *cached_mode_set;


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