From 36111270aa23dffdc757cb76f4ca01f3425bfbf2 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Fri, 17 Apr 2020 14:50:13 +0300 Subject: [PATCH] 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 --- 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;