Commit d28232b4 authored by Stanislaw Gruszka's avatar Stanislaw Gruszka Committed by John W. Linville

iwlwifi: fix scan abort

Fix possible double priv->mutex lock introduced by commit
a69b03e9
"iwlwifi: cancel scan watchdog in iwl_bg_abort_scan" .
We can not call cancel_delayed_work_sync(&priv->scan_check) with
priv->mutex locked because workqueue function iwl_bg_scan_check()
take that lock internally.

We do not need to synchronize when canceling priv->scan_check work.
We can avoid races (sending double abort command or send no
command at all) using STATUS_SCAN_ABORT bit. Moreover
current iwl_bg_scan_check() code seems to be broken, as
we should not send abort commands when currently aborting.
Signed-off-by: default avatarStanislaw Gruszka <sgruszka@redhat.com>
CC: stable@kernel.org
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 16345910
...@@ -429,10 +429,9 @@ void iwl_bg_scan_check(struct work_struct *data) ...@@ -429,10 +429,9 @@ void iwl_bg_scan_check(struct work_struct *data)
return; return;
mutex_lock(&priv->mutex); mutex_lock(&priv->mutex);
if (test_bit(STATUS_SCANNING, &priv->status) || if (test_bit(STATUS_SCANNING, &priv->status) &&
test_bit(STATUS_SCAN_ABORTING, &priv->status)) { !test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
IWL_DEBUG_SCAN(priv, "Scan completion watchdog resetting " IWL_DEBUG_SCAN(priv, "Scan completion watchdog (%dms)\n",
"adapter (%dms)\n",
jiffies_to_msecs(IWL_SCAN_CHECK_WATCHDOG)); jiffies_to_msecs(IWL_SCAN_CHECK_WATCHDOG));
if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) if (!test_bit(STATUS_EXIT_PENDING, &priv->status))
...@@ -498,12 +497,11 @@ void iwl_bg_abort_scan(struct work_struct *work) ...@@ -498,12 +497,11 @@ void iwl_bg_abort_scan(struct work_struct *work)
!test_bit(STATUS_GEO_CONFIGURED, &priv->status)) !test_bit(STATUS_GEO_CONFIGURED, &priv->status))
return; return;
mutex_lock(&priv->mutex); cancel_delayed_work(&priv->scan_check);
cancel_delayed_work_sync(&priv->scan_check); mutex_lock(&priv->mutex);
set_bit(STATUS_SCAN_ABORTING, &priv->status); if (test_bit(STATUS_SCAN_ABORTING, &priv->status))
iwl_send_scan_abort(priv); iwl_send_scan_abort(priv);
mutex_unlock(&priv->mutex); mutex_unlock(&priv->mutex);
} }
EXPORT_SYMBOL(iwl_bg_abort_scan); EXPORT_SYMBOL(iwl_bg_abort_scan);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment