summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-09-26 15:34:07 +0200
committerThomas Haller <thaller@redhat.com>2016-09-26 17:10:07 +0200
commit7a5537ee8604039ab9bedf8685873a4a1ed83d8f (patch)
tree3b191e214bb38755edca2fd3952e0958cbdf4948
parentee860696010c530b66a5d39ad0be3944184770d5 (diff)
downloadNetworkManager-7a5537ee8604039ab9bedf8685873a4a1ed83d8f.tar.gz
policy: fix owner-ship of specific_object in can_auto_connect()
NMPolicy:auto_activate_device() would wrongly not free the specific_object, although it is documented as transfer-full. The only implementation of can_auto_connect() that returned a specific-object is NMDeviceWifi:can_auto_connect(). So, there wasn't any actual bug or memory leak. Fixes: 4c028c7cefd413df3c824658fc007a96f44b0c9b
-rw-r--r--src/devices/bluetooth/nm-device-bt.c10
-rw-r--r--src/devices/nm-device.c2
-rw-r--r--src/devices/wifi/nm-device-olpc-mesh.c2
-rw-r--r--src/devices/wifi/nm-device-wifi.c6
-rw-r--r--src/nm-policy.c2
5 files changed, 15 insertions, 7 deletions
diff --git a/src/devices/bluetooth/nm-device-bt.c b/src/devices/bluetooth/nm-device-bt.c
index 67ae15bc82..77b4c667b9 100644
--- a/src/devices/bluetooth/nm-device-bt.c
+++ b/src/devices/bluetooth/nm-device-bt.c
@@ -136,7 +136,9 @@ can_auto_connect (NMDevice *device,
NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device);
guint32 bt_type;
- if (!NM_DEVICE_CLASS (nm_device_bt_parent_class)->can_auto_connect (device, connection, specific_object))
+ nm_assert (!specific_object || !*specific_object);
+
+ if (!NM_DEVICE_CLASS (nm_device_bt_parent_class)->can_auto_connect (device, connection, NULL))
return FALSE;
/* Can't auto-activate a DUN connection without ModemManager */
@@ -351,9 +353,9 @@ complete_connection (NMDevice *device,
static void
ppp_stats (NMModem *modem,
- guint32 in_bytes,
- guint32 out_bytes,
- gpointer user_data)
+ guint32 in_bytes,
+ guint32 out_bytes,
+ gpointer user_data)
{
g_signal_emit (NM_DEVICE_BT (user_data), signals[PPP_STATS], 0, in_bytes, out_bytes);
}
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index c7fc22e529..c6d5f87f6b 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -3191,6 +3191,8 @@ can_auto_connect (NMDevice *self,
{
NMSettingConnection *s_con;
+ nm_assert (!specific_object || !*specific_object);
+
s_con = nm_connection_get_setting_connection (connection);
if (!nm_setting_connection_get_autoconnect (s_con))
return FALSE;
diff --git a/src/devices/wifi/nm-device-olpc-mesh.c b/src/devices/wifi/nm-device-olpc-mesh.c
index 77a963756d..32ebac3b74 100644
--- a/src/devices/wifi/nm-device-olpc-mesh.c
+++ b/src/devices/wifi/nm-device-olpc-mesh.c
@@ -103,6 +103,8 @@ can_auto_connect (NMDevice *device,
NMConnection *connection,
char **specific_object)
{
+ nm_assert (!specific_object || !*specific_object);
+
return FALSE;
}
diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c
index e106c88a8a..f98a40be63 100644
--- a/src/devices/wifi/nm-device-wifi.c
+++ b/src/devices/wifi/nm-device-wifi.c
@@ -961,7 +961,9 @@ can_auto_connect (NMDevice *device,
const char *method, *mode;
guint64 timestamp = 0;
- if (!NM_DEVICE_CLASS (nm_device_wifi_parent_class)->can_auto_connect (device, connection, specific_object))
+ nm_assert (!specific_object || !*specific_object);
+
+ if (!NM_DEVICE_CLASS (nm_device_wifi_parent_class)->can_auto_connect (device, connection, NULL))
return FALSE;
s_wifi = nm_connection_get_setting_wireless (connection);
@@ -988,7 +990,7 @@ can_auto_connect (NMDevice *device,
ap = find_first_compatible_ap (self, connection, FALSE);
if (ap) {
/* All good; connection is usable */
- *specific_object = (char *) nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap));
+ NM_SET_OUT (specific_object, g_strdup (nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap))));
return TRUE;
}
diff --git a/src/nm-policy.c b/src/nm-policy.c
index 0e437d9d4c..7d34732051 100644
--- a/src/nm-policy.c
+++ b/src/nm-policy.c
@@ -672,7 +672,7 @@ auto_activate_device (gpointer user_data)
NMPolicy *self;
NMPolicyPrivate *priv;
NMSettingsConnection *best_connection;
- char *specific_object = NULL;
+ gs_free char *specific_object = NULL;
GPtrArray *connections;
GSList *connection_list;
guint i;