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
This commit is contained in:
Beniamino Galvani 2016-01-19 21:20:46 +01:00
parent 7231626d31
commit 701d98acc5

View file

@ -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);