mwifiex: check driver status in connect and scan handlers
authorAmitkumar Karwar <akarwar@marvell.com>
Wed, 7 Jan 2015 11:57:39 +0000 (03:57 -0800)
committerKalle Valo <kvalo@codeaurora.org>
Fri, 23 Jan 2015 17:03:15 +0000 (19:03 +0200)
Ignore scan and connection requests from cfg80211 when driver
unload is in process or previous command has timed out due to
a firmware bug. This patch fixes corner case system crash
issues.

Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Cathy Luo <cluo@marvell.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/mwifiex/cfg80211.c
drivers/net/wireless/mwifiex/scan.c

index b3bf2cd150b796023edf8f4f48bca37ae0218d4f..7be1e9b83fd0204faff07bb0127cf1fc4a46e974 100644 (file)
@@ -1786,6 +1786,7 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
                         struct cfg80211_connect_params *sme)
 {
        struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
+       struct mwifiex_adapter *adapter = priv->adapter;
        int ret;
 
        if (GET_BSS_ROLE(priv) != MWIFIEX_BSS_ROLE_STA) {
@@ -1800,6 +1801,13 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
                return -EALREADY;
        }
 
+       if (adapter->surprise_removed || adapter->is_cmd_timedout) {
+               wiphy_err(wiphy,
+                         "%s: Ignore connection. Card removed or FW in bad state\n",
+                         dev->name);
+               return -EFAULT;
+       }
+
        wiphy_dbg(wiphy, "info: Trying to associate to %s and bssid %pM\n",
                  (char *) sme->ssid, sme->bssid);
 
index 984a7a4fa93b4920600255ec79966b3ab5272e49..e304f0731647f158ff962a40e5f6c688ec2a6a1f 100644 (file)
@@ -1429,6 +1429,12 @@ int mwifiex_scan_networks(struct mwifiex_private *priv,
                return -EBUSY;
        }
 
+       if (adapter->surprise_removed || adapter->is_cmd_timedout) {
+               dev_err(adapter->dev,
+                       "Ignore scan. Card removed or firmware in bad state\n");
+               return -EFAULT;
+       }
+
        spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags);
        adapter->scan_processing = true;
        spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags);