[PATCH] vpn-provider: VPN driver pointer was not cleared

Jukka Rissanen jukka.rissanen at linux.intel.com
Mon Nov 26 04:47:23 PST 2012


When VPN driver is unregistered, we must clear the corresponding
pointer in provider struct. If this is not done we will have
already freed memory access in clean_provider() function.
---
 vpn/vpn-provider.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/vpn/vpn-provider.c b/vpn/vpn-provider.c
index a69b458..f529122 100644
--- a/vpn/vpn-provider.c
+++ b/vpn/vpn-provider.c
@@ -2104,9 +2104,24 @@ int vpn_provider_driver_register(struct vpn_provider_driver *driver)
 
 void vpn_provider_driver_unregister(struct vpn_provider_driver *driver)
 {
+	GHashTableIter iter;
+	gpointer value, key;
+
 	DBG("driver %p name %s", driver, driver->name);
 
 	driver_list = g_slist_remove(driver_list, driver);
+
+	g_hash_table_iter_init(&iter, provider_hash);
+	while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+		struct vpn_provider *provider = value;
+
+		if (provider != NULL && provider->driver != NULL &&
+				provider->driver->type == driver->type &&
+				g_strcmp0(provider->driver->name,
+							driver->name) == 0) {
+			provider->driver = NULL;
+		}
+	}
 }
 
 static gboolean check_vpn_count(gpointer data)
-- 
1.7.11.4




More information about the connman mailing list