summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2013-08-05 17:15:07 -0400
committerDan Williams <dcbw@redhat.com>2013-08-06 16:36:51 -0500
commit588547b3434039deb602db00359cf30e7602e3d9 (patch)
tree69d79b7a73691497d07f8d67d08c6d902296de7b
parent1d3ae22905ffbcbd23f1300df18af317ae35f32b (diff)
downloadNetworkManager-588547b3434039deb602db00359cf30e7602e3d9.tar.gz
core: fix cleanup of NMDevices that fail construction
We were leaving signal handlers attached to devices that failed in constructor() (and also leaking the available_connections hash). Fix that.
-rw-r--r--src/devices/nm-device.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index b0f12b0361..49ad6a357b 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -360,8 +360,6 @@ static void
nm_device_init (NMDevice *self)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
- NMPlatform *platform;
- int i;
priv->type = NM_DEVICE_TYPE_UNKNOWN;
priv->capabilities = NM_DEVICE_CAP_NM_SUPPORTED;
@@ -371,16 +369,6 @@ nm_device_init (NMDevice *self)
priv->rfkill_type = RFKILL_TYPE_UNKNOWN;
priv->autoconnect = DEFAULT_AUTOCONNECT;
priv->available_connections = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, NULL);
-
- /* Watch for external IP config changes */
- platform = nm_platform_get ();
- for (i = 0; i < n_platform_ip_signals; i++) {
- g_signal_connect (platform, platform_ip_signals[i],
- G_CALLBACK (device_ip_changed), self);
- }
-
- g_signal_connect (platform, NM_PLATFORM_LINK_CHANGED,
- G_CALLBACK (link_changed_cb), self);
}
static void
@@ -506,6 +494,8 @@ constructor (GType type,
GObject *object;
NMDevice *dev;
NMDevicePrivate *priv;
+ NMPlatform *platform;
+ int i;
object = G_OBJECT_CLASS (nm_device_parent_class)->constructor (type,
n_construct_params,
@@ -539,6 +529,16 @@ constructor (GType type,
update_ip6_privacy_save (dev);
update_ip_config (dev);
+ /* Watch for external IP config changes */
+ platform = nm_platform_get ();
+ for (i = 0; i < n_platform_ip_signals; i++) {
+ g_signal_connect (platform, platform_ip_signals[i],
+ G_CALLBACK (device_ip_changed), dev);
+ }
+
+ g_signal_connect (platform, NM_PLATFORM_LINK_CHANGED,
+ G_CALLBACK (link_changed_cb), dev);
+
priv->initialized = TRUE;
return object;
@@ -4904,6 +4904,7 @@ dispose (GObject *object)
}
g_hash_table_unref (priv->available_connections);
+ priv->available_connections = NULL;
activation_source_clear (self, TRUE, AF_INET);
activation_source_clear (self, TRUE, AF_INET6);
@@ -4940,6 +4941,8 @@ finalize (GObject *object)
g_free (priv->type_desc);
if (priv->dhcp_anycast_address)
g_byte_array_free (priv->dhcp_anycast_address, TRUE);
+ if (priv->available_connections)
+ g_hash_table_unref (priv->available_connections);
G_OBJECT_CLASS (nm_device_parent_class)->finalize (object);
}