From 5b3763336466f2c55611437cb924aeee45f7203e Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Wed, 6 Jun 2012 17:07:46 +0300 Subject: [PATCH] P2P: Fix scan_res_handler setting for p2p_scan The previous version set scan_res_handler unconditionally and then cleared it if scan request failed. This can result in incorrect clearing of the handler to NULL for a previously started scan that has not yet completed. This can make p2p_find command fail to use the start-after-scan-completion mechanism in some cases. Fix this by setting scan_res_handler properly after having verified that the driver command for starting the scan was successful. Signed-hostap: Jouni Malinen intended-for: hostap-1 --- wpa_supplicant/p2p_supplicant.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 8fcdf4117..bbf4578c4 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -112,7 +112,6 @@ static int wpas_p2p_scan(void *ctx, enum p2p_scan_type type, int freq, struct wpabuf *wps_ie, *ies; int social_channels[] = { 2412, 2437, 2462, 0, 0 }; size_t ielen; - int was_in_p2p_scan; if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) return -1; @@ -163,19 +162,18 @@ static int wpas_p2p_scan(void *ctx, enum p2p_scan_type type, int freq, break; } - was_in_p2p_scan = wpa_s->scan_res_handler == wpas_p2p_scan_res_handler; - wpa_s->scan_res_handler = wpas_p2p_scan_res_handler; ret = wpa_drv_scan(wpa_s, ¶ms); wpabuf_free(ies); if (ret) { - wpa_s->scan_res_handler = NULL; - if (wpa_s->scanning || was_in_p2p_scan) { + if (wpa_s->scanning || + wpa_s->scan_res_handler == wpas_p2p_scan_res_handler) { wpa_s->p2p_cb_on_scan_complete = 1; ret = 1; } - } + } else + wpa_s->scan_res_handler = wpas_p2p_scan_res_handler; return ret; }