From 76c34d48ed4a1f6fe60511c99e692befb1490260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Tue, 17 Sep 2013 18:59:48 +0200 Subject: [PATCH] core,settings: do not call functions with connection==NULL (rh #1008151) check 'req' and 'connection' variables. Apparently, they can be NULL on some circumstances. NetworkManager[2830]: (p6p1): device state change: secondaries -> disconnected (reason 'connection-removed') [90 30 38] NetworkManager[2830]: (p6p1): deactivating device (reason 'connection-removed') [38] kernel: [ 2623.609111] NetworkManager[2830]: segfault at 50 ip 00007f1a309bf6a1 sp 00007fffc59e67e0 error 6 in NetworkManager[7f1a30915000+104000] NetworkManager[2830]: (nm-device.c:5043):nm_device_state_changed: runtime check failed: (in_state_changed == FALSE) NetworkManager[2830]: (p6p1): device state change: disconnected -> failed (reason 'secondary-connection-failed') [30 120 54] NetworkManager[2830]: nm_act_request_get_connection: assertion `NM_IS_ACT_REQUEST (req)' failed NetworkManager[2830]: nm_connection_get_id: assertion `connection != NULL' failed NetworkManager[2830]: Activation (p6p1) failed for connection '(null)' NetworkManager[2830]: nm_settings_connection_get_timestamp: assertion `connection != NULL' failed abrt[2882]: Saved core dump of pid 2830 (/usr/sbin/NetworkManager) to /var/tmp/abrt/ccpp-2013-09-15-11:38:39-2830 (18952192 bytes) systemd[1]: NetworkManager.service: main process exited, code=dumped, status=11/SEGV systemd[1]: Unit NetworkManager.service entered failed state. https://bugzilla.redhat.com/show_bug.cgi?id=1008151 --- src/devices/nm-device.c | 6 +++--- src/settings/nm-settings-connection.c | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 038ac1f219..8489e05358 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -6013,11 +6013,11 @@ nm_device_state_changed (NMDevice *device, nm_dispatcher_call (DISPATCHER_ACTION_UP, nm_act_request_get_connection (req), device, NULL, NULL); break; case NM_DEVICE_STATE_FAILED: - connection = nm_act_request_get_connection (req); + connection = nm_device_get_connection (device); nm_log_warn (LOGD_DEVICE | LOGD_WIFI, "Activation (%s) failed for connection '%s'", nm_device_get_iface (device), - nm_connection_get_id (connection)); + connection ? nm_connection_get_id (connection) : ""); /* Notify any slaves of the unexpected failure */ nm_device_master_release_slaves (device, TRUE); @@ -6027,7 +6027,7 @@ nm_device_state_changed (NMDevice *device, * failed (zero timestamp), connections that succeeded (non-zero timestamp), * and those we haven't tried yet (no timestamp). */ - if (!nm_settings_connection_get_timestamp (NM_SETTINGS_CONNECTION (connection), NULL)) { + if (connection && !nm_settings_connection_get_timestamp (NM_SETTINGS_CONNECTION (connection), NULL)) { nm_settings_connection_update_timestamp (NM_SETTINGS_CONNECTION (connection), (guint64) 0, TRUE); diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c index 78d2c9b393..2cd2f0d0ae 100644 --- a/src/settings/nm-settings-connection.c +++ b/src/settings/nm-settings-connection.c @@ -1563,7 +1563,7 @@ gboolean nm_settings_connection_get_timestamp (NMSettingsConnection *connection, guint64 *out_timestamp) { - g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (connection), 0); + g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (connection), FALSE); if (out_timestamp) *out_timestamp = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection)->timestamp; @@ -1591,6 +1591,8 @@ nm_settings_connection_update_timestamp (NMSettingsConnection *connection, gsize len; GError *error = NULL; + g_return_if_fail (NM_IS_SETTINGS_CONNECTION (connection)); + /* Update timestamp in private storage */ priv->timestamp = timestamp; priv->timestamp_set = TRUE; @@ -1640,6 +1642,8 @@ nm_settings_connection_read_and_fill_timestamp (NMSettingsConnection *connection GError *err = NULL; char *tmp_str; + g_return_if_fail (NM_IS_SETTINGS_CONNECTION (connection)); + /* Get timestamp from database file */ timestamps_file = g_key_file_new (); g_key_file_load_from_file (timestamps_file, SETTINGS_TIMESTAMPS_FILE, G_KEY_FILE_KEEP_COMMENTS, NULL);