core: fix use-after-free caused by incorrect HAL device resync code
This commit is contained in:

committed by
Dan Williams

parent
dc09f62e2e
commit
ee3286c870
@@ -1479,12 +1479,11 @@ static void
|
|||||||
sync_devices (NMManager *self)
|
sync_devices (NMManager *self)
|
||||||
{
|
{
|
||||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
||||||
GSList *devices;
|
GSList *devices = NULL;
|
||||||
GSList *iter;
|
GSList *iter;
|
||||||
|
|
||||||
/* Remove devices which are no longer known to HAL */
|
/* Keep devices still known to HAL; get rid of ones HAL no longer knows about */
|
||||||
devices = g_slist_copy (priv->devices);
|
for (iter = priv->devices; iter; iter = iter->next) {
|
||||||
for (iter = devices; iter; iter = iter->next) {
|
|
||||||
NMDevice *device = NM_DEVICE (iter->data);
|
NMDevice *device = NM_DEVICE (iter->data);
|
||||||
const char *udi = nm_device_get_udi (device);
|
const char *udi = nm_device_get_udi (device);
|
||||||
|
|
||||||
@@ -1493,15 +1492,14 @@ sync_devices (NMManager *self)
|
|||||||
nm_device_set_managed (device, TRUE, NM_DEVICE_STATE_REASON_NOW_MANAGED);
|
nm_device_set_managed (device, TRUE, NM_DEVICE_STATE_REASON_NOW_MANAGED);
|
||||||
else
|
else
|
||||||
nm_device_set_managed (device, FALSE, NM_DEVICE_STATE_REASON_NOW_UNMANAGED);
|
nm_device_set_managed (device, FALSE, NM_DEVICE_STATE_REASON_NOW_UNMANAGED);
|
||||||
} else {
|
devices = g_slist_prepend (devices, device);
|
||||||
priv->devices = g_slist_delete_link (priv->devices, iter);
|
} else
|
||||||
remove_one_device (self, device);
|
remove_one_device (self, device);
|
||||||
}
|
}
|
||||||
}
|
g_slist_free (priv->devices);
|
||||||
|
priv->devices = devices;
|
||||||
|
|
||||||
g_slist_free (devices);
|
/* Ask HAL for new devices */
|
||||||
|
|
||||||
/* Get any new ones */
|
|
||||||
nm_hal_manager_query_devices (priv->hal_mgr);
|
nm_hal_manager_query_devices (priv->hal_mgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user