wifi: Set interface to NULL in interface_removed
authorYu A Wang <arron.wang@intel.com>
Wed, 21 Dec 2011 07:14:58 +0000 (02:14 -0500)
committerDaniel Wagner <daniel.wagner@bmw-carit.de>
Thu, 5 Jan 2012 09:50:45 +0000 (10:50 +0100)
Currently we set wifi interface to NULL in interface_remove_callback.
commit 80e2e08b4887c4e133d3ca7d42ac844fbb974bb8 avoid to use stale
pointer by get wifi pointer through interface, but interface already
removed and should be NULL, then the interface value in wifi will never
set to NULL and will be a wild pointer. Which may cause connman crash
when we connect wifi service after we disable the wifi. This issue does
not exist in latest connman due to connect-service method is removed.

we can set wifi interface in interface_removed which called in remove_interface
in supplicant.c, because after interface is freed in supplicant, we should not
hold this pointer anymore.

Fixes BMC#24364

plugins/wifi.c

index 5f41b25..0860938 100644 (file)
@@ -236,23 +236,6 @@ static void interface_create_callback(int result,
        connman_device_set_powered(wifi->device, TRUE);
 }
 
-static void interface_remove_callback(int result,
-                                       GSupplicantInterface *interface,
-                                                       void *user_data)
-{
-       struct wifi_data *wifi;
-
-       wifi = g_supplicant_interface_get_data(interface);
-
-       DBG("result %d wifi %p", result, wifi);
-
-       if (result < 0 || wifi == NULL)
-               return;
-
-       wifi->interface = NULL;
-}
-
-
 static int wifi_enable(struct connman_device *device)
 {
        struct wifi_data *wifi = connman_device_get_data(device);
@@ -286,9 +269,7 @@ static int wifi_disable(struct connman_device *device)
 
        remove_networks(device, wifi);
 
-       ret = g_supplicant_interface_remove(wifi->interface,
-                                               interface_remove_callback,
-                                               NULL);
+       ret = g_supplicant_interface_remove(wifi->interface, NULL, NULL);
        if (ret < 0)
                return ret;
 
@@ -1100,6 +1081,7 @@ static void interface_removed(GSupplicantInterface *interface)
                return;
        }
 
+       wifi->interface = NULL;
        connman_device_set_powered(wifi->device, FALSE);
 }