Skip to content

Commit a1d2b15

Browse files
jmberg-intelIgor
authored andcommitted
iwlagn: fix dangling scan request
If iwl_scan_initiate() fails for any reason, priv->scan_request and priv->scan_vif are left dangling. This can lead to a crash later when iwl_bg_scan_completed() tries to run a pending scan request. In practice, this seems to be very rare due to the STATUS_SCANNING check earlier. That check, however, is wrong -- it should allow a scan to be queued when a reset/roc scan is going on. When a normal scan is already going on, a new one can't be issued by mac80211, so that code can be removed completely. I introduced this bug when adding off-channel support in commit 266af4c. Cc: stable@kernel.org [3.0] Reported-by: Peng Yan <peng.yan@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent 4a5a61f commit a1d2b15

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

drivers/net/wireless/iwlwifi/iwl-scan.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -405,31 +405,33 @@ int iwl_mac_hw_scan(struct ieee80211_hw *hw,
405405

406406
mutex_lock(&priv->mutex);
407407

408-
if (test_bit(STATUS_SCANNING, &priv->status) &&
409-
priv->scan_type != IWL_SCAN_NORMAL) {
410-
IWL_DEBUG_SCAN(priv, "Scan already in progress.\n");
411-
ret = -EAGAIN;
412-
goto out_unlock;
413-
}
414-
415-
/* mac80211 will only ask for one band at a time */
416-
priv->scan_request = req;
417-
priv->scan_vif = vif;
418-
419408
/*
420409
* If an internal scan is in progress, just set
421410
* up the scan_request as per above.
422411
*/
423412
if (priv->scan_type != IWL_SCAN_NORMAL) {
424-
IWL_DEBUG_SCAN(priv, "SCAN request during internal scan\n");
413+
IWL_DEBUG_SCAN(priv,
414+
"SCAN request during internal scan - defer\n");
415+
priv->scan_request = req;
416+
priv->scan_vif = vif;
425417
ret = 0;
426-
} else
418+
} else {
419+
priv->scan_request = req;
420+
priv->scan_vif = vif;
421+
/*
422+
* mac80211 will only ask for one band at a time
423+
* so using channels[0] here is ok
424+
*/
427425
ret = iwl_scan_initiate(priv, vif, IWL_SCAN_NORMAL,
428426
req->channels[0]->band);
427+
if (ret) {
428+
priv->scan_request = NULL;
429+
priv->scan_vif = NULL;
430+
}
431+
}
429432

430433
IWL_DEBUG_MAC80211(priv, "leave\n");
431434

432-
out_unlock:
433435
mutex_unlock(&priv->mutex);
434436

435437
return ret;

0 commit comments

Comments
 (0)