File bsc#1136712-0001-Low-contoller-scheduler-guard-hash-table-deletes-1.1.patch of Package pacemaker.14737

From ea1e4c6327c12b912fa8fb6666e90d1505fe9992 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Wed, 2 May 2018 20:27:42 -0500
Subject: [PATCH] Low: contoller,scheduler: guard hash table deletes

In particular, it is possible for the controller to exit and call
throttle_fini() before throttle_init() had a chance to be called. Without a
guard, g_hash_table_destroy() would log an (otherwise harmless) assertion.
---
 crmd/throttle.c         | 10 ++++++++--
 lib/pengine/container.c |  4 +++-
 lib/pengine/native.c    |  4 +++-
 lib/pengine/unpack.c    |  4 +++-
 4 files changed, 17 insertions(+), 5 deletions(-)

Index: pacemaker-1.1.16+20170320.77ea74d/crmd/throttle.c
===================================================================
--- pacemaker-1.1.16+20170320.77ea74d.orig/crmd/throttle.c
+++ pacemaker-1.1.16+20170320.77ea74d/crmd/throttle.c
@@ -564,8 +564,14 @@ throttle_init(void)
 void
 throttle_fini(void)
 {
-    mainloop_timer_del(throttle_timer); throttle_timer = NULL;
-    g_hash_table_destroy(throttle_records); throttle_records = NULL;
+    if (throttle_timer != NULL) {
+        mainloop_timer_del(throttle_timer);
+        throttle_timer = NULL;
+    }
+    if (throttle_records != NULL) {
+        g_hash_table_destroy(throttle_records);
+        throttle_records = NULL;
+    }
 }
 
 int
Index: pacemaker-1.1.16+20170320.77ea74d/lib/pengine/native.c
===================================================================
--- pacemaker-1.1.16+20170320.77ea74d.orig/lib/pengine/native.c
+++ pacemaker-1.1.16+20170320.77ea74d/lib/pengine/native.c
@@ -77,7 +77,9 @@ native_add_running(resource_t * rsc, nod
                     node_t *local_node = NULL;
 
                     /* make sure it doesn't come up again */
-                    g_hash_table_destroy(rsc->allowed_nodes);
+                    if (rsc->allowed_nodes != NULL) {
+                        g_hash_table_destroy(rsc->allowed_nodes);
+                    }
                     rsc->allowed_nodes = node_hash_from_list(data_set->nodes);
                     g_hash_table_iter_init(&gIter, rsc->allowed_nodes);
                     while (g_hash_table_iter_next(&gIter, NULL, (void **)&local_node)) {
Index: pacemaker-1.1.16+20170320.77ea74d/lib/pengine/unpack.c
===================================================================
--- pacemaker-1.1.16+20170320.77ea74d.orig/lib/pengine/unpack.c
+++ pacemaker-1.1.16+20170320.77ea74d/lib/pengine/unpack.c
@@ -2682,7 +2682,9 @@ unpack_rsc_op_failure(resource_t * rsc,
         }
         crm_warn("Making sure %s doesn't come up again", fail_rsc->id);
         /* make sure it doesn't come up again */
-        g_hash_table_destroy(fail_rsc->allowed_nodes);
+        if (fail_rsc->allowed_nodes != NULL) {
+            g_hash_table_destroy(fail_rsc->allowed_nodes);
+        }
         fail_rsc->allowed_nodes = node_hash_from_list(data_set->nodes);
         g_hash_table_foreach(fail_rsc->allowed_nodes, set_node_score, &score);
     }
openSUSE Build Service is sponsored by