[PATCH v3 17/21] vpn-provider: Unregister provider from dbus when freed

Jukka Rissanen jukka.rissanen at linux.intel.com
Fri Nov 30 01:30:50 PST 2012


The provider object was not unregistered from dbus watch
when the provider was removed which caused free memory access
error.
---
 vpn/vpn-provider.c | 68 +++++++++++++++++++++++++++++-------------------------
 1 file changed, 36 insertions(+), 32 deletions(-)

diff --git a/vpn/vpn-provider.c b/vpn/vpn-provider.c
index 9bbb10f..0b164c0 100644
--- a/vpn/vpn-provider.c
+++ b/vpn/vpn-provider.c
@@ -1436,12 +1436,48 @@ int vpn_provider_indicate_error(struct vpn_provider *provider,
 	return 0;
 }
 
+static int connection_unregister(struct vpn_provider *provider)
+{
+	DBG("provider %p path %s", provider, provider->path);
+
+	if (provider->path == NULL)
+		return -EALREADY;
+
+	g_dbus_unregister_interface(connection, provider->path,
+				VPN_CONNECTION_INTERFACE);
+
+	g_free(provider->path);
+	provider->path = NULL;
+
+	return 0;
+}
+
+static int connection_register(struct vpn_provider *provider)
+{
+	DBG("provider %p path %s", provider, provider->path);
+
+	if (provider->path != NULL)
+		return -EALREADY;
+
+	provider->path = g_strdup_printf("%s/connection/%s", VPN_PATH,
+						provider->identifier);
+
+	g_dbus_register_interface(connection, provider->path,
+				VPN_CONNECTION_INTERFACE,
+				connection_methods, connection_signals,
+				NULL, provider, NULL);
+
+	return 0;
+}
+
 static void unregister_provider(gpointer data)
 {
 	struct vpn_provider *provider = data;
 
 	configuration_count_del();
 
+	connection_unregister(provider);
+
 	vpn_provider_unref(provider);
 }
 
@@ -1518,38 +1554,6 @@ static void provider_dbus_ident(char *ident)
 	}
 }
 
-static int connection_unregister(struct vpn_provider *provider)
-{
-	if (provider->path == NULL)
-		return -EALREADY;
-
-	g_dbus_unregister_interface(connection, provider->path,
-				VPN_CONNECTION_INTERFACE);
-
-	g_free(provider->path);
-	provider->path = NULL;
-
-	return 0;
-}
-
-static int connection_register(struct vpn_provider *provider)
-{
-	DBG("provider %p path %s", provider, provider->path);
-
-	if (provider->path != NULL)
-		return -EALREADY;
-
-	provider->path = g_strdup_printf("%s/connection/%s", VPN_PATH,
-						provider->identifier);
-
-	g_dbus_register_interface(connection, provider->path,
-				VPN_CONNECTION_INTERFACE,
-				connection_methods, connection_signals,
-				NULL, provider, NULL);
-
-	return 0;
-}
-
 static struct vpn_provider *provider_create_from_keyfile(GKeyFile *keyfile,
 		const char *ident)
 {
-- 
1.7.11.4




More information about the connman mailing list