From: Jouni Malinen Date: Mon, 5 Dec 2016 09:43:16 +0000 (+0200) Subject: nl80211: Fix scan_state update in no pending scan state X-Git-Tag: hostap_2_7~2065 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f346fadc8aaeeac44ebefbae7e97f2035b9ff22;p=thirdparty%2Fhostap.git nl80211: Fix scan_state update in no pending scan state Commit adcd7c4b0bd02bead77f884f52782a813f5243bb ('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 --- diff --git a/src/drivers/driver_nl80211_event.c b/src/drivers/driver_nl80211_event.c index c77e21ed4..994bc4c10 100644 --- a/src/drivers/driver_nl80211_event.c +++ b/src/drivers/driver_nl80211_event.c @@ -2116,9 +2116,10 @@ static void do_process_drv_event(struct i802_bss *bss, int cmd, case NL80211_CMD_NEW_SCAN_RESULTS: wpa_dbg(drv->ctx, MSG_DEBUG, "nl80211: New scan results available"); + if (drv->last_scan_cmd != NL80211_CMD_VENDOR) + drv->scan_state = SCAN_COMPLETED; drv->scan_complete_events = 1; if (drv->last_scan_cmd == NL80211_CMD_TRIGGER_SCAN) { - drv->scan_state = SCAN_COMPLETED; eloop_cancel_timeout(wpa_driver_nl80211_scan_timeout, drv, drv->ctx); drv->last_scan_cmd = 0; @@ -2135,8 +2136,9 @@ static void do_process_drv_event(struct i802_bss *bss, int cmd, break; case NL80211_CMD_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; + if (drv->last_scan_cmd == NL80211_CMD_TRIGGER_SCAN) { /* * Need to indicate that scan results are available in * order not to make wpa_supplicant stop its scanning.