[PATCH v2] P2P: Disconnect P2P group on supplicant deinit

nirav shah nirav.j2.shah
Tue Apr 3 17:55:34 PDT 2012


When a supplicant is deinited and shutting, adding code to disconnect
from p2p_group. Found root causing the memory leak on variable
dbus_groupobj_path on exiting supplicant.

Signed-hostap: Nirav Shah <nirav.j2.shah at intel.com>
Signed-hostap: Angie Chinchilla <angie.v.chinchilla at intel.com>
---
v2: Calling the function wpas_p2p_disconnect in wpas_p2p_deinit_global
instead of wpa_supplicant_deinit_iface as it is a more appropriate location

 wpa_supplicant/p2p_supplicant.c |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index f4e43a8..2fc2139 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -2478,7 +2478,7 @@ void wpas_p2p_deinit(struct wpa_supplicant *wpa_s)
  */
 void wpas_p2p_deinit_global(struct wpa_global *global)
 {
-	struct wpa_supplicant *wpa_s, *tmp;
+	struct wpa_supplicant *wpa_s, *p2p_interface;
 	char *ifname;
 
 	if (global->p2p == NULL)
@@ -2492,17 +2492,21 @@ void wpas_p2p_deinit_global(struct wpa_global *global)
 		wpa_s = wpa_s->next;
 	while (wpa_s) {
 		enum wpa_driver_if_type type;
-		tmp = global->ifaces;
-		while (tmp &&
-		       (tmp == wpa_s ||
-			tmp->p2p_group_interface == NOT_P2P_GROUP_INTERFACE)) {
-			tmp = tmp->next;
+		p2p_interface = global->ifaces;
+		/* Find the next P2P group interface */
+		while (p2p_interface &&
+		       (p2p_interface == wpa_s ||
+			p2p_interface->p2p_group_interface
+				== NOT_P2P_GROUP_INTERFACE)) {
+			p2p_interface = p2p_interface->next;
 		}
-		if (tmp == NULL)
+		if (p2p_interface == NULL)
 			break;
-		ifname = os_strdup(tmp->ifname);
-		type = wpas_p2p_if_type(tmp->p2p_group_interface);
-		wpa_supplicant_remove_iface(global, tmp, 0);
+		ifname = os_strdup(p2p_interface->ifname);
+		type = wpas_p2p_if_type(p2p_interface->p2p_group_interface);
+		/* Disconnect from the p2p group and deinit the interface */
+		wpas_p2p_disconnect(p2p_interface);
+
 		if (ifname)
 			wpa_drv_if_remove(wpa_s, type, ifname);
 		os_free(ifname);
-- 
1.7.4.1




More information about the Hostap mailing list