ofono: Free network_info
authorDaniel Wagner <daniel.wagner@bmw-carit.de>
Tue, 15 Mar 2011 14:02:08 +0000 (15:02 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Wed, 16 Mar 2011 09:29:29 +0000 (10:29 +0100)
The network_info data structure is not freed. Also the
error path does not handle the freeing of the data structure
correctly.

Reported by: Henri Bragge <henri.bragge@ixonos.com>

plugins/ofono.c

index 3f4e986..3e71441 100644 (file)
@@ -362,6 +362,8 @@ static void remove_network(gpointer data)
        struct network_info *info = data;
 
        connman_network_unref(info->network);
+
+       g_free(info);
 }
 
 static char *get_ident(const char *path)
@@ -604,8 +606,11 @@ static int add_network(struct connman_device *device,
 
        connman_network_set_string(network, "Path", path);
        hash_path = connman_network_get_string(network, "Path");
-       if (hash_path == NULL)
-               goto error;
+       if (hash_path == NULL) {
+               connman_network_unref(network);
+               g_free(info);
+               return -EIO;
+       }
 
        create_service(network);
 
@@ -1721,7 +1726,7 @@ static gboolean context_changed(DBusConnection *connection,
                return TRUE;
 
        if (!pending_network_is_available(info->network)) {
-               remove_network(info->network);
+               g_hash_table_remove(network_hash, path);
                return TRUE;
        }