From e16e8ab7fba19203536ed5f9518c31265c8775f0 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 8 Aug 2013 15:57:57 -0500 Subject: [PATCH] policy: prevent double-deactivation of an NMActiveConnection after it's removed When a connection is removed from NMSettings, it gets deactivated. That was happening once in response to the now-removed connection's visibility changing to invisible to everyone, and a second time in response to the actual removal signal. Unfortunately the second time the NMActiveConnection is already cleaned up and in the DEACTIVATED state, and has no priv->device, which causes great hilarity when nm_device_set_state() is called with NULL. _deactivate_if_active() should only try to deactivate NMActiveConnections that actually are active. --- src/nm-policy.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/nm-policy.c b/src/nm-policy.c index ff6f71a2e..525fbc774 100644 --- a/src/nm-policy.c +++ b/src/nm-policy.c @@ -1811,9 +1811,11 @@ _deactivate_if_active (NMManager *manager, NMConnection *connection) active = nm_manager_get_active_connections (manager); for (iter = active; iter; iter = g_slist_next (iter)) { NMActiveConnection *ac = iter->data; + NMActiveConnectionState state = nm_active_connection_get_state (ac); GError *error = NULL; - if (nm_active_connection_get_connection (ac) == connection) { + if (nm_active_connection_get_connection (ac) == connection && + (state <= NM_ACTIVE_CONNECTION_STATE_ACTIVATED)) { if (!nm_manager_deactivate_connection (manager, nm_active_connection_get_path (ac), NM_DEVICE_STATE_REASON_CONNECTION_REMOVED,