diff options
author | Jukka Rissanen <jukka.rissanen@linux.intel.com> | 2012-11-30 11:30:50 +0200 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2012-11-30 15:01:19 +0200 |
commit | d27c42180b7d0d6fe0e7516019d61d6022421799 (patch) | |
tree | 0e6b81ed34652b9ba04ec09f70d4b4407e793bf0 /vpn/vpn-provider.c | |
parent | e70f2a6b7f7ed34099830e92a3cfa7be409ab7e9 (diff) | |
download | connman-d27c42180b7d0d6fe0e7516019d61d6022421799.tar.gz connman-d27c42180b7d0d6fe0e7516019d61d6022421799.tar.bz2 connman-d27c42180b7d0d6fe0e7516019d61d6022421799.zip |
vpn-provider: Unregister provider from dbus when freed
The provider object was not unregistered from dbus watch
when the provider was removed which caused free memory access
error.
Diffstat (limited to 'vpn/vpn-provider.c')
-rw-r--r-- | vpn/vpn-provider.c | 68 |
1 files changed, 36 insertions, 32 deletions
diff --git a/vpn/vpn-provider.c b/vpn/vpn-provider.c index 9bbb10f8..0b164c04 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) { |