core: fix segfault on initialization of macvlan and gre device

The link_changed method expects a valid info parameter.
NMDeviceMacvlan and NMDeviceGre calls link_changed
during construction for initialization.

As it was before, NMDeviceMacvlan and NMDeviceGre passed
NULL as NMPlatformLink, causing NM to segfault.

(Regression was introduced in 0e361e894c)

https://bugzilla.redhat.com/show_bug.cgi?id=997396

Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
Thomas Haller 2013-08-21 12:36:14 +02:00
parent bfce3f7dc8
commit 34d28376ed
2 changed files with 18 additions and 8 deletions

View file

@ -59,14 +59,12 @@ enum {
/**************************************************************/
static void
link_changed (NMDevice *device, NMPlatformLink *info)
update_properties (NMDevice *device)
{
NMDeviceGrePrivate *priv = NM_DEVICE_GRE_GET_PRIVATE (device);
GObject *object = G_OBJECT (device);
NMPlatformGreProperties props;
NM_DEVICE_CLASS (nm_device_gre_parent_class)->link_changed (device, info);
if (!nm_platform_gre_get_properties (nm_device_get_ifindex (device), &props)) {
nm_log_warn (LOGD_HW, "(%s): could not read gre properties",
nm_device_get_iface (device));
@ -108,6 +106,13 @@ link_changed (NMDevice *device, NMPlatformLink *info)
g_object_thaw_notify (object);
}
static void
link_changed (NMDevice *device, NMPlatformLink *info)
{
NM_DEVICE_CLASS (nm_device_gre_parent_class)->link_changed (device, info);
update_properties (device);
}
/**************************************************************/
NMDevice *
@ -130,7 +135,7 @@ nm_device_gre_init (NMDeviceGre *self)
static void
constructed (GObject *object)
{
link_changed (NM_DEVICE (object), NULL);
update_properties (NM_DEVICE (object));
G_OBJECT_CLASS (nm_device_gre_parent_class)->constructed (object);
}

View file

@ -54,14 +54,12 @@ enum {
/**************************************************************/
static void
link_changed (NMDevice *device, NMPlatformLink *info)
update_properties (NMDevice *device)
{
NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE (device);
GObject *object = G_OBJECT (device);
NMPlatformMacvlanProperties props;
NM_DEVICE_CLASS (nm_device_macvlan_parent_class)->link_changed (device, info);
if (!nm_platform_macvlan_get_properties (nm_device_get_ifindex (device), &props)) {
nm_log_warn (LOGD_HW, "(%s): could not read macvlan properties",
nm_device_get_iface (device));
@ -88,6 +86,13 @@ link_changed (NMDevice *device, NMPlatformLink *info)
g_object_thaw_notify (object);
}
static void
link_changed (NMDevice *device, NMPlatformLink *info)
{
NM_DEVICE_CLASS (nm_device_macvlan_parent_class)->link_changed (device, info);
update_properties (device);
}
/**************************************************************/
NMDevice *
@ -110,7 +115,7 @@ nm_device_macvlan_init (NMDeviceMacvlan *self)
static void
constructed (GObject *object)
{
link_changed (NM_DEVICE (object), NULL);
update_properties (NM_DEVICE (object));
G_OBJECT_CLASS (nm_device_macvlan_parent_class)->constructed (object);
}