nl80211: Fix scan_state update in no pending scan state

Commit adcd7c4b0b ('nl80211: Support
vendor scan together with normal scan') made the drv->scan_state updates
for NL80211_CMD_NEW_SCAN_RESULTS and NL80211_CMD_SCAN_ABORTED
conditional on drv->last_scan_cmd being NL80211_CMD_TRIGGER_SCAN. This
missed the part about the possibility of last_scan_cmd == 0 and an
externally started cfg80211 scan is ending. This could leave
drv->scan_state into SCAN_STARTED state even after the scan was
completed. Consequently, hwsim test cases could get stuck in reset()
handler waiting for scan to terminate.

Fix this by updating drv->scan_state also in drv->last_scan_cmd == 0
case.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Jouni Malinen 2016-12-05 11:43:16 +02:00 committed by Jouni Malinen
parent 80fe420ab2
commit 9f346fadc8

View file

@ -2116,9 +2116,10 @@ static void do_process_drv_event(struct i802_bss *bss, int cmd,
case NL80211_CMD_NEW_SCAN_RESULTS: case NL80211_CMD_NEW_SCAN_RESULTS:
wpa_dbg(drv->ctx, MSG_DEBUG, wpa_dbg(drv->ctx, MSG_DEBUG,
"nl80211: New scan results available"); "nl80211: New scan results available");
if (drv->last_scan_cmd != NL80211_CMD_VENDOR)
drv->scan_state = SCAN_COMPLETED;
drv->scan_complete_events = 1; drv->scan_complete_events = 1;
if (drv->last_scan_cmd == NL80211_CMD_TRIGGER_SCAN) { if (drv->last_scan_cmd == NL80211_CMD_TRIGGER_SCAN) {
drv->scan_state = SCAN_COMPLETED;
eloop_cancel_timeout(wpa_driver_nl80211_scan_timeout, eloop_cancel_timeout(wpa_driver_nl80211_scan_timeout,
drv, drv->ctx); drv, drv->ctx);
drv->last_scan_cmd = 0; drv->last_scan_cmd = 0;
@ -2135,8 +2136,9 @@ static void do_process_drv_event(struct i802_bss *bss, int cmd,
break; break;
case NL80211_CMD_SCAN_ABORTED: case NL80211_CMD_SCAN_ABORTED:
wpa_dbg(drv->ctx, MSG_DEBUG, "nl80211: Scan aborted"); wpa_dbg(drv->ctx, MSG_DEBUG, "nl80211: Scan aborted");
if (drv->last_scan_cmd == NL80211_CMD_TRIGGER_SCAN) { if (drv->last_scan_cmd != NL80211_CMD_VENDOR)
drv->scan_state = SCAN_ABORTED; drv->scan_state = SCAN_ABORTED;
if (drv->last_scan_cmd == NL80211_CMD_TRIGGER_SCAN) {
/* /*
* Need to indicate that scan results are available in * Need to indicate that scan results are available in
* order not to make wpa_supplicant stop its scanning. * order not to make wpa_supplicant stop its scanning.