Search Linux Wireless

[RFC] mac80211: Prevent possible BUG on suspend.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



PM code has a watchdog to trigger a BUG when suspend callback
is not returning in several seconds. Some WLAN hardware has
longer timeouts for non-interruptible configuration-related
operations, leading to the watchdog timeout while
ieee80211_scan_cancel is waiting on a mutex.

The patch checks if interface mutex is already held and rejects
suspend if there is a possibility of locking.
---
 net/mac80211/pm.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
index 9ee7164..468d2e5 100644
--- a/net/mac80211/pm.c
+++ b/net/mac80211/pm.c
@@ -37,6 +37,25 @@ int __ieee80211_suspend(struct ieee80211_hw *hw,
struct cfg80211_wowlan *wowlan)
 	if (!local->open_count)
 		goto suspend;

+	/* PM code has a watchdog to trigger a BUG when
+	 * suspend callback is not returning in several seconds.
+	 * Some WLAN hardware has longer timeouts for non-interruptible
+	 * configuration-related operations, leading to the watchdog
+	 * timeout while ieee80211_scan_cancel is waiting on the mutex.
+	 *
+	 * The code below checks if interface mutex is already held
+	 * and rejects suspend if there is a possibility of locking.
+	 *
+	 * It's a bit racy, but handles most of cases.
+	 */
+	if (mutex_trylock(&local->mtx))
+		mutex_unlock(&local->mtx);
+	else {
+		wiphy_warn(hw->wiphy, "Suspend when operation "
+			"is in progress. Suspend aborted.\n");
+		return -EBUSY;
+	}
+
 	ieee80211_scan_cancel(local);

 	if (hw->flags & IEEE80211_HW_AMPDU_AGGREGATION) {
-- 
1.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux