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 b557f91a1b)
This commit is contained in:
Beniamino Galvani 2015-07-31 18:06:43 +02:00
parent ad0ab5e827
commit 8482f06090

View file

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