From 701d98acc5fde5e089a33304e83491350f8656d5 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 19 Jan 2016 21:20:46 +0100 Subject: [PATCH] device: fix check on device state in carrier_changed() The function can now be called on unrealized devices before the initial unmanaged flags are set and for those devices nm_device_get_managed() will return TRUE. Since we only accept states > UNMANAGED, return early when the condition is not met. Fixes the following failed assertion: carrier_changed: assertion 'priv->state >= NM_DEVICE_STATE_UNAVAILABLE' failed https://bugzilla.gnome.org/show_bug.cgi?id=760844 --- src/devices/nm-device.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 93782a4503..6e9a156d8c 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -1272,7 +1272,7 @@ carrier_changed (NMDevice *self, gboolean carrier) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - if (!nm_device_get_managed (self)) + if (priv->state <= NM_DEVICE_STATE_UNMANAGED) return; nm_device_recheck_available_connections (self); @@ -1304,8 +1304,6 @@ carrier_changed (NMDevice *self, gboolean carrier) } if (carrier) { - g_warn_if_fail (priv->state >= NM_DEVICE_STATE_UNAVAILABLE); - if (priv->state == NM_DEVICE_STATE_UNAVAILABLE) { nm_device_queue_state (self, NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_CARRIER); @@ -1324,8 +1322,6 @@ carrier_changed (NMDevice *self, gboolean carrier) update_dynamic_ip_setup (self); } } else { - g_return_if_fail (priv->state >= NM_DEVICE_STATE_UNAVAILABLE); - if (priv->state == NM_DEVICE_STATE_UNAVAILABLE) { if (nm_device_queued_state_peek (self) >= NM_DEVICE_STATE_DISCONNECTED) nm_device_queued_state_clear (self);