mutter/SOURCES/idle-monitor-reset-fix.patch

129 lines
4.2 KiB
Diff
Raw Permalink Normal View History

2020-04-28 09:36:08 +00:00
From 35333114a991440d671e3642170aa080df45a171 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
Date: Mon, 16 Sep 2019 16:17:48 +0200
Subject: [PATCH 1/3] idle-monitor: Make helper function static
It wasn't used outside the file, so no reason to not have it static.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/799
---
src/backends/meta-idle-monitor-private.h | 1 -
src/backends/meta-idle-monitor.c | 8 ++++----
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/backends/meta-idle-monitor-private.h b/src/backends/meta-idle-monitor-private.h
index 93948b14b..cc08f8c8e 100644
--- a/src/backends/meta-idle-monitor-private.h
+++ b/src/backends/meta-idle-monitor-private.h
@@ -54,7 +54,6 @@ struct _MetaIdleMonitorClass
GObjectClass parent_class;
};
-void _meta_idle_monitor_watch_fire (MetaIdleMonitorWatch *watch);
void meta_idle_monitor_reset_idletime (MetaIdleMonitor *monitor);
#endif /* META_IDLE_MONITOR_PRIVATE_H */
diff --git a/src/backends/meta-idle-monitor.c b/src/backends/meta-idle-monitor.c
index e83d6c778..de1c7e0ba 100644
--- a/src/backends/meta-idle-monitor.c
+++ b/src/backends/meta-idle-monitor.c
@@ -54,8 +54,8 @@ static GParamSpec *obj_props[PROP_LAST];
G_DEFINE_TYPE (MetaIdleMonitor, meta_idle_monitor, G_TYPE_OBJECT)
-void
-_meta_idle_monitor_watch_fire (MetaIdleMonitorWatch *watch)
+static void
+meta_idle_monitor_watch_fire (MetaIdleMonitorWatch *watch)
{
MetaIdleMonitor *monitor;
guint id;
@@ -324,7 +324,7 @@ idle_monitor_dispatch_timeout (GSource *source,
if (ready_time > now)
return G_SOURCE_CONTINUE;
- _meta_idle_monitor_watch_fire (watch);
+ meta_idle_monitor_watch_fire (watch);
g_source_set_ready_time (watch->timeout_source, -1);
return G_SOURCE_CONTINUE;
@@ -511,7 +511,7 @@ meta_idle_monitor_reset_idletime (MetaIdleMonitor *monitor)
if (watch->timeout_msec == 0)
{
- _meta_idle_monitor_watch_fire ((MetaIdleMonitorWatch *) watch);
+ meta_idle_monitor_watch_fire ((MetaIdleMonitorWatch *) watch);
}
else
{
--
2.23.0
From 07276cf94d84489d450c17b7dec5a8075c60440a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
Date: Mon, 16 Sep 2019 16:36:05 +0200
Subject: [PATCH 2/3] idle-monitor: Remove redundant type cast
No need to type cast a `MetaIdleMonitorWatch *` to a
`MetaIdleMonitorWatch *`.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/799
---
src/backends/meta-idle-monitor.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/backends/meta-idle-monitor.c b/src/backends/meta-idle-monitor.c
index de1c7e0ba..e5124abc1 100644
--- a/src/backends/meta-idle-monitor.c
+++ b/src/backends/meta-idle-monitor.c
@@ -511,7 +511,7 @@ meta_idle_monitor_reset_idletime (MetaIdleMonitor *monitor)
if (watch->timeout_msec == 0)
{
- meta_idle_monitor_watch_fire ((MetaIdleMonitorWatch *) watch);
+ meta_idle_monitor_watch_fire (watch);
}
else
{
--
2.23.0
From 73c1f387765ef528c7323e6e7ca3c05899cfcc4a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
Date: Mon, 16 Sep 2019 16:36:51 +0200
Subject: [PATCH 3/3] idle-monitor: Reset timeout before firing watch
The watch might be removed during firing, meaning the source is
destroyed after returning. Avoid use-after-free by unsetting the timeout
before firing. Returning G_SOURCE_CONTINUE in that case is harmless, as
source is destroyed.
Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/796
https://gitlab.gnome.org/GNOME/mutter/merge_requests/799
---
src/backends/meta-idle-monitor.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/backends/meta-idle-monitor.c b/src/backends/meta-idle-monitor.c
index e5124abc1..9fa481742 100644
--- a/src/backends/meta-idle-monitor.c
+++ b/src/backends/meta-idle-monitor.c
@@ -324,9 +324,10 @@ idle_monitor_dispatch_timeout (GSource *source,
if (ready_time > now)
return G_SOURCE_CONTINUE;
- meta_idle_monitor_watch_fire (watch);
g_source_set_ready_time (watch->timeout_source, -1);
+ meta_idle_monitor_watch_fire (watch);
+
return G_SOURCE_CONTINUE;
}
--
2.23.0