From ef151c3f046956b6a7991605c7e3355f1376e758 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 23 Apr 2013 14:01:24 -0500 Subject: [PATCH] core: fix memory leak get_virtual_iface_name() returns an allocated interface name which we must free; that wasn't being done when attempting to find the interface for which a virtual interface needs to be created. Also throw in a cleanup for the given-device-doesn't-exist case just to make it clearer when the interface name is freed. --- src/nm-manager.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/nm-manager.c b/src/nm-manager.c index 760c0cf3a9..057bc3c1b7 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -2758,6 +2758,7 @@ nm_manager_activate_connection (NMManager *manager, NMDevice *master_device = NULL; NMConnection *master_connection = NULL; NMActiveConnection *master_ac = NULL, *ac = NULL; + gboolean matched; g_return_val_if_fail (manager != NULL, NULL); g_return_val_if_fail (connection != NULL, NULL); @@ -2803,13 +2804,15 @@ nm_manager_activate_connection (NMManager *manager, g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_DEVICE, "Failed to determine connection's virtual interface name"); return NULL; - } else if (g_strcmp0 (iface, nm_device_get_ip_iface (device)) != 0) { + } + + matched = g_str_equal (iface, nm_device_get_ip_iface (device)); + g_free (iface); + if (!matched) { g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_DEVICE, "Device given by path did not match connection's virtual interface name"); - g_free (iface); return NULL; } - g_free (iface); } } else { /* Virtual connections (VLAN, bond, etc) may not specify a device @@ -2831,6 +2834,7 @@ nm_manager_activate_connection (NMManager *manager, } device = find_device_by_ip_iface (manager, iface); + g_free (iface); if (!device) { /* Create it */ device = system_create_virtual_device (manager, connection);