Message ID | 1333500934-11338-1-git-send-email-nirav.j2.shah@intel.com |
---|---|
State | Accepted |
Commit | 103b8f4dea947df496080f646a8a955d24fcdb3d |
Headers | show |
On Tue, Apr 03, 2012 at 05:55:34PM -0700, nirav shah wrote: > 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. > 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 Thanks! Applied with some changes: > diff --git 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; I removed renaming of that variable to make the real changes easier to see. > - 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); The new code path will go through wpa_drv_if_remove() call in wpas_p2p_group_delete(), so this one here will result in duplicated attempt to remove the interface. I removed this to get rid of the duplicated call.
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);