From e36096b3a4ff0239f40513aa25d81364cfe2e9c4 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 2 Jun 2014 13:00:51 +0200 Subject: [PATCH 1/1] core: properly handle carrier_changed() for devices in state UNMANAGED Fixes the following g_warn(): #0 0x0000003370c504e9 in g_logv () from /lib64/libglib-2.0.so.0 #1 0x0000003370c5063f in g_log () from /lib64/libglib-2.0.so.0 #2 0x0000003370c50956 in g_warn_message () from /lib64/libglib-2.0.so.0 #3 0x0000000000439962 in carrier_changed (device=0x1d94300, carrier=1) at devices/nm-device.c:1021 #4 0x0000000000488f12 in carrier_changed (device=0x1d94300, carrier=1) at devices/nm-device-ethernet.c:1646 #5 0x0000000000434c94 in nm_device_set_carrier (device=device entry=0x1d94300, carrier=1) at devices/nm-device.c:1104 #6 0x0000000000434dd5 in check_carrier (device=device entry=0x1d94300) at devices/nm-device.c:1298 #7 0x0000000000434ef8 in constructed (object=0x1d94300) at devices/nm-device.c:550 #8 0x0000003371c15d87 in g_object_new_internal () from /lib64/libgobject-2.0.so.0 #9 0x0000003371c17814 in g_object_new_valist () from /lib64/libgobject-2.0.so.0 #10 0x0000003371c17c11 in g_object_new () from /lib64/libgobject-2.0.so.0 #11 0x000000000048bc2e in nm_device_ethernet_new (platform_device=platform_device entry=0x1d82e58) at devices/nm-device-ethernet.c:336 #12 0x000000000047c600 in platform_link_added (self=0x1d70150, ifindex=ifindex entry=2, plink=plink entry=0x1d82e58, reason=reason entry=NM_PLATFORM_REASON_INTERNAL) at nm-manager.c:1954 #13 0x000000000047c7db in platform_link_cb (platform=, ifindex=2, plink=0x1d82e58, change_type=, reason=NM_PLATFORM_REASON_INTERNAL, user_data=0x1d70150) at nm-manager.c:2038 #14 0x0000003371805d8c in ffi_call_unix64 () from /lib64/libffi.so.6 #15 0x00000033718056bc in ffi_call () from /lib64/libffi.so.6 #16 0x0000003371c10ad8 in g_cclosure_marshal_generic () from /lib64/libgobject-2.0.so.0 #17 0x0000003371c10298 in g_closure_invoke () from /lib64/libgobject-2.0.so.0 #18 0x0000003371c2235d in signal_emit_unlocked_R () from /lib64/libgobject-2.0.so.0 #19 0x0000003371c2a0f2 in g_signal_emit_valist () from /lib64/libgobject-2.0.so.0 #20 0x0000003371c2a3af in g_signal_emit () from /lib64/libgobject-2.0.so.0 #21 0x000000000044f6ba in nm_platform_query_devices () at platform/nm-platform.c:330 #22 0x000000000047de4c in nm_manager_start (self=0x1d70150) at nm-manager.c:4025 #23 0x0000000000429d31 in main (argc=1, argv=0x7fffb4c31628) at main.c:654 Signed-off-by: Thomas Haller --- src/devices/nm-device.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 6a7ec5e..4e5c9dc 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -989,6 +989,9 @@ carrier_changed (NMDevice *device, gboolean carrier) if (!nm_device_get_managed (device)) return; + if (priv->state <= NM_DEVICE_STATE_UNMANAGED) + return; + nm_device_recheck_available_connections (device); /* ignore-carrier devices ignore all carrier-down events */ @@ -1018,8 +1021,6 @@ carrier_changed (NMDevice *device, 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 (device, NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_CARRIER); @@ -1032,8 +1033,6 @@ carrier_changed (NMDevice *device, gboolean carrier) nm_device_emit_recheck_auto_activate (device); } } else { - g_return_if_fail (priv->state >= NM_DEVICE_STATE_UNAVAILABLE); - if (priv->state == NM_DEVICE_STATE_UNAVAILABLE) { if (nm_device_queued_state_peek (device) >= NM_DEVICE_STATE_DISCONNECTED) nm_device_queued_state_clear (device); -- 1.9.3