diff options
author | Thomas Haller <thaller@redhat.com> | 2023-04-07 13:34:34 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2023-04-27 08:40:12 +0200 |
commit | aede228974beed3764352e0e31096a70b8d2a49f (patch) | |
tree | 67d9549f3a6879658068e06b69784f8e82454098 | |
parent | 0dd4724446fdef043fddc9f1e20569cacb78474d (diff) | |
download | NetworkManager-aede228974beed3764352e0e31096a70b8d2a49f.tar.gz |
core: assert that devices are not registered when disposing NMPolicy
NMDevice holds a reference to NMManager, which holds a reference to NMPolicy.
It is not possible that we try to dispose NMPolicy while there are still devices
registered. That would be a bug, that we need to find and solve
differently. Add an assertion instead of trying to handle it.
-rw-r--r-- | src/core/nm-policy.c | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/src/core/nm-policy.c b/src/core/nm-policy.c index ef0d8456ba..9309026e56 100644 --- a/src/core/nm-policy.c +++ b/src/core/nm-policy.c @@ -2870,8 +2870,9 @@ dispose(GObject *object) { NMPolicy *self = NM_POLICY(object); NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); - GHashTableIter h_iter; - NMDevice *device; + + nm_assert(!c_list_is_empty(&priv->policy_auto_activate_lst_head)); + nm_assert(g_hash_table_size(priv->devices) == 0); nm_clear_g_object(&priv->default_ac4); nm_clear_g_object(&priv->default_ac6); @@ -2879,11 +2880,6 @@ dispose(GObject *object) nm_clear_g_object(&priv->activating_ac6); nm_clear_pointer(&priv->pending_active_connections, g_hash_table_unref); - while ((device = c_list_first_entry(&priv->policy_auto_activate_lst_head, - NMDevice, - policy_auto_activate_lst))) - _auto_activate_device_clear(self, device, FALSE); - g_slist_free_full(priv->pending_secondaries, (GDestroyNotify) pending_secondary_data_free); priv->pending_secondaries = NULL; @@ -2902,12 +2898,6 @@ dispose(GObject *object) g_clear_object(&priv->dns_manager); } - g_hash_table_iter_init(&h_iter, priv->devices); - while (g_hash_table_iter_next(&h_iter, (gpointer *) &device, NULL)) { - g_hash_table_iter_remove(&h_iter); - devices_list_unregister(self, device); - } - /* The manager should have disposed of ActiveConnections already, which * will have called active_connection_removed() and thus we don't need * to clean anything up. Assert that this is TRUE. |