summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2019-03-28 10:31:32 +0100
committerLubomir Rintel <lkundrak@v3.sk>2019-03-28 14:57:04 +0100
commitf034f17ff69c52d81589e55ba815404f1ca53b7d (patch)
tree5e652e1fe3f61fe00d1cd08e2cc3a176c5bfc6ee
parent768001473279d2ce70599ee1838eb0d594b51223 (diff)
downloadNetworkManager-f034f17ff69c52d81589e55ba815404f1ca53b7d.tar.gz
settings: keep the added connection alive for a bit longer
Fixes a crash on failed AddAndActivate: $ ip link set eth0 down $ nmcli d conn eth0 Error: Failed to add/activate new connection: Connection 'eth0' is not available on device eth0 because device has no carrier <NetworkManager crashes> #3 0x000055555558b6c5 in _nm_g_return_if_fail_warning #4 0x00005555557008c7 in nm_settings_has_connection #5 0x0000555555700e5f in pk_add_cb #6 0x0000555555726e30 in pk_call_cb #7 0x0000555555726e30 in pk_call_cb #8 0x0000555555726e30 in pk_call_cb #9 0x00005555555aaea8 in _call_id_invoke_callback #10 0x00005555555ab2e8 in _call_on_idle https://github.com/NetworkManager/NetworkManager/pull/325
-rw-r--r--src/settings/nm-settings.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c
index fd1d316a2d..9298826dbf 100644
--- a/src/settings/nm-settings.c
+++ b/src/settings/nm-settings.c
@@ -1138,7 +1138,7 @@ pk_add_cb (NMAuthChain *chain,
NMAuthCallResult result;
GError *error = NULL;
NMConnection *connection = NULL;
- NMSettingsConnection *added = NULL;
+ gs_unref_object NMSettingsConnection *added = NULL;
NMSettingsAddCallback callback;
gpointer callback_data;
NMAuthSubject *subject;
@@ -1169,6 +1169,12 @@ pk_add_cb (NMAuthChain *chain,
save_to_disk = GPOINTER_TO_UINT (nm_auth_chain_get_data (chain, "save-to-disk"));
added = nm_settings_add_connection (self, connection, save_to_disk, &error);
+
+ /* The callback may remove the connection from the settings manager (e.g.
+ * because it's found to be incompatible with the device on AddAndActivate).
+ * But we need to keep it alive for a bit longer, precisely to check wehther
+ * it's still known to the setting manager. */
+ g_object_ref (added);
}
callback = nm_auth_chain_get_data (chain, "callback");