From e4d7cb745302c895a8b3de18957b15c4f55a1b99 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 9 Jul 2024 10:44:21 +0200 Subject: [PATCH] policy: assert that the auto-activate list is empty on dispose We are currently asserting that the list of devices waiting for auto-activation in NMPolicy is not empty. This condition is always false because: - NMDevice holds a reference to NMManager - NMManager holds a reference to NMPolicy - on dispose, NMDevice asserts that it's not in NMPolicy's auto-activate list Therefore if there is any NMDevice alive, NMPolicy must be alive as well. Instead, if there is no NMDevice alive the list must be empty. The assertion could fail only when the NMPolicy instance gets disposed, which usually doesn't happen because it's still referenced at shutdown. Fixes: aede228974be ('core: assert that devices are not registered when disposing NMPolicy') (cherry picked from commit 27b646cfa1f0e4cde13316a82b8d479a69752d12) (cherry picked from commit 1b51404703e232a6c72bb01130e1c7eb7618ea08) --- src/core/nm-policy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/nm-policy.c b/src/core/nm-policy.c index db588db7d6..8ee664074a 100644 --- a/src/core/nm-policy.c +++ b/src/core/nm-policy.c @@ -3114,7 +3114,7 @@ dispose(GObject *object) NMPolicy *self = NM_POLICY(object); NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); - nm_assert(!c_list_is_empty(&priv->policy_auto_activate_lst_head)); + 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);