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.
This commit is contained in:
Jouni Malinen 2011-09-29 16:52:23 +03:00 committed by Jouni Malinen
parent 0096c42740
commit 0c96fd6d03
2 changed files with 5 additions and 0 deletions

View file

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

View file

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