From 8482f060907acc1dfe66c73d046f8eba63dd35bd Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 31 Jul 2015 18:06:43 +0200 Subject: [PATCH] device: don't clear @master on cleanup when the link is still enslaved Don't clear NMDevice @master in nm_device_cleanup() if the device link is still enslaved because this causes an inconsistent state in which the slave in included in the @slaves field of master device but @master of slave device is NULL. In such state, if the master link gets deleted, NM receives a change event for each slave and a deletion event for the master; the change events should also remove slaves from @slaves of master device, but since their @master field is NULL the removal can't be performed. Later, when the master deletion event is received, @slaves is not empty in dispose() of NMDevice and the following assertion is triggered: dispose: runtime check failed: (priv->slaves == NULL) https://bugzilla.redhat.com/show_bug.cgi?id=1243371 (cherry picked from commit b557f91a1bca67b05f69185f244319e764a4a21d) --- src/devices/nm-device.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 7fab9273b5..e52c68b460 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -8028,9 +8028,11 @@ nm_device_cleanup (NMDevice *self, NMDeviceStateReason reason, CleanupType clean nm_device_master_release_slaves (self); /* slave: mark no longer enslaved */ - g_clear_object (&priv->master); - priv->enslaved = FALSE; - g_object_notify (G_OBJECT (self), NM_DEVICE_MASTER); + if (nm_platform_link_get_master (NM_PLATFORM_GET, priv->ifindex) <= 0) { + g_clear_object (&priv->master); + priv->enslaved = FALSE; + g_object_notify (G_OBJECT (self), NM_DEVICE_MASTER); + } /* Take out any entries in the routing table and any IP address the device had. */ ifindex = nm_device_get_ip_ifindex (self);