mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-04 18:00:18 +01:00
ifnet: ensure an error is always returned when add fails
There are many places where the function can fail without returning an error, leading to a crash. Fix this.
This commit is contained in:
parent
d4a5e2b1c8
commit
2f3e978f57
1 changed files with 7 additions and 2 deletions
|
|
@ -321,11 +321,11 @@ add_connection (NMSettingsPlugin *config,
|
|||
* asked to write it to disk.
|
||||
*/
|
||||
if (!ifnet_can_write_connection (source, error))
|
||||
return NULL;
|
||||
goto out;
|
||||
|
||||
if (save_to_disk) {
|
||||
if (!ifnet_add_new_connection (source, CONF_NET_FILE, WPA_SUPPLICANT_CONF, NULL, NULL, error))
|
||||
return NULL;
|
||||
goto out;
|
||||
reload_connections (config);
|
||||
new = g_hash_table_lookup (priv->connections, nm_connection_get_uuid (source));
|
||||
} else {
|
||||
|
|
@ -337,6 +337,11 @@ add_connection (NMSettingsPlugin *config,
|
|||
}
|
||||
}
|
||||
|
||||
out:
|
||||
if (!new && error && !*error) {
|
||||
g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
|
||||
"The ifnet plugin cannot add the connection (unknown error).");
|
||||
}
|
||||
return (NMSettingsConnection *) new;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue