Browse Source

P2P: Do not leave P2P scan handler registered if scan fails

If the initial attempt to start a scan for p2p_find fails, an error
is reported. However, the P2P scan handler and search state was
left behind. That can result in unexpected behavior when the next
non-P2P scan results are indicated. Avoid this by clearing the
P2P search state on failure.
Jouni Malinen 13 years ago
parent
commit
0c96fd6d03
2 changed files with 5 additions and 0 deletions
  1. 2 0
      src/p2p/p2p.c
  2. 3 0
      wpa_supplicant/p2p_supplicant.c

+ 2 - 0
src/p2p/p2p.c

@@ -907,6 +907,8 @@ int p2p_find(struct p2p_data *p2p, unsigned int timeout,
 	} else {
 	} else {
 		wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Failed to start "
 		wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Failed to start "
 			"p2p_scan");
 			"p2p_scan");
+		p2p_set_state(p2p, P2P_IDLE);
+		eloop_cancel_timeout(p2p_find_timeout, p2p, NULL);
 	}
 	}
 
 
 	return res;
 	return res;

+ 3 - 0
wpa_supplicant/p2p_supplicant.c

@@ -149,6 +149,9 @@ static int wpas_p2p_scan(void *ctx, enum p2p_scan_type type, int freq,
 
 
 	wpabuf_free(ies);
 	wpabuf_free(ies);
 
 
+	if (ret < 0)
+		wpa_s->scan_res_handler = NULL;
+
 	return ret;
 	return ret;
 }
 }