Patchwork P2P: p2p_group_remove should fail on non p2p interface

login
register
mail settings
Submitter Michael Naumov
Date July 17, 2012, 1:09 a.m.
Message ID <1342487367-8090-1-git-send-email-michael.naumov@intel.com>
Download mbox | patch
Permalink /patch/171302/
State Superseded
Headers show

Comments

Michael Naumov - July 17, 2012, 1:09 a.m.
p2p_group_remove should only attempt to remove p2p group
interfaces and fail on non p2p group interfaces

Signed-hostap: Michael Naumov <michael.naumov@intel.com>
Signed-hostap: Nirav Shah <nirav.j2.shah@intel.com>
---
 wpa_supplicant/p2p_supplicant.c |   15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
Johannes Berg - July 17, 2012, 9:30 a.m.
On Mon, 2012-07-16 at 18:09 -0700, Michael Naumov wrote:
> @@ -4795,9 +4802,7 @@ int wpas_p2p_disconnect(struct wpa_supplicant *wpa_s)
>  		return -1;
>  
>  	wpa_s->removal_reason = P2P_GROUP_REMOVAL_REQUESTED;
> -	wpas_p2p_group_delete(wpa_s, 0);
> -
> -	return 0;
> +	return wpas_p2p_group_delete(wpa_s, 0);

Doesn't that leave the removal reason wrong/invalid/... when the removal
shouldn't go through?

johannes

Patch

diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index 218ed2f..99a4ca9 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -214,7 +214,7 @@  static struct wpa_supplicant * wpas_get_p2p_group(struct wpa_supplicant *wpa_s,
 }
 
 
-static void wpas_p2p_group_delete(struct wpa_supplicant *wpa_s, int silent)
+static int wpas_p2p_group_delete(struct wpa_supplicant *wpa_s, int silent)
 {
 	struct wpa_ssid *ssid;
 	char *gtype;
@@ -234,6 +234,11 @@  static void wpas_p2p_group_delete(struct wpa_supplicant *wpa_s, int silent)
 				break;
 			ssid = ssid->next;
 		}
+		if (ssid == NULL) {
+			wpa_printf(MSG_ERROR, "P2P: P2P group interface "
+				   "not found");
+			return -1;
+		}
 	}
 	if (wpa_s->p2p_group_interface == P2P_GROUP_INTERFACE_GO)
 		gtype = "GO";
@@ -295,7 +300,7 @@  static void wpas_p2p_group_delete(struct wpa_supplicant *wpa_s, int silent)
 		if (wpa_s && ifname)
 			wpa_drv_if_remove(wpa_s, type, ifname);
 		os_free(ifname);
-		return;
+		return 0;
 	}
 
 	wpa_printf(MSG_DEBUG, "P2P: Remove temporary group network");
@@ -328,6 +333,8 @@  static void wpas_p2p_group_delete(struct wpa_supplicant *wpa_s, int silent)
 		wpa_supplicant_ap_deinit(wpa_s);
 	else
 		wpa_drv_deinit_p2p_cli(wpa_s);
+
+	return 0;
 }
 
 
@@ -4795,9 +4802,7 @@  int wpas_p2p_disconnect(struct wpa_supplicant *wpa_s)
 		return -1;
 
 	wpa_s->removal_reason = P2P_GROUP_REMOVAL_REQUESTED;
-	wpas_p2p_group_delete(wpa_s, 0);
-
-	return 0;
+	return wpas_p2p_group_delete(wpa_s, 0);
 }