]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Fix scan_res_handler setting for p2p_scan
authorJouni Malinen <jouni@qca.qualcomm.com>
Wed, 6 Jun 2012 14:07:46 +0000 (17:07 +0300)
committerJouni Malinen <j@w1.fi>
Wed, 6 Jun 2012 14:07:46 +0000 (17:07 +0300)
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 <jouni@qca.qualcomm.com>
intended-for: hostap-1

wpa_supplicant/p2p_supplicant.c

index 8fcdf41177e1f23d816962bf924caea4e7a524e4..bbf4578c43904c89f23ab35424b7cf61dc7f6477 100644 (file)
@@ -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, &params);
 
        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;
 }