Search Linux Wireless

[PATCH 2/3] mwifiex: fix adhoc mode NULL pointer issue

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

 



From: Yogesh Ashok Powar <yogeshp@xxxxxxxxxxx>

mwifiex_cfg80211_assoc() handles both infra and adhoc modes.
"sme" parameter is from cfg80211 stack and only meaningful
to infra mode. For adhoc mode, NULL is passed to "sme" as a
dummy parameter. We should differentiate infra/adhoc modes
correctly to avoid access sme structure in adhoc mode.

Signed-off-by: Yogesh Ashok Powar <yogeshp@xxxxxxxxxxx>
Signed-off-by: Amitkumar Karwar <akarwar@xxxxxxxxxxx>
Signed-off-by: Bing Zhao <bzhao@xxxxxxxxxxx>
---
 drivers/net/wireless/mwifiex/cfg80211.c |   33 ++++++++++++++++---------------
 1 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c
index f4d240e..80f367f 100644
--- a/drivers/net/wireless/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/mwifiex/cfg80211.c
@@ -1044,27 +1044,28 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
 				mwifiex_channels_to_cfg80211_channel_type
 				(priv->adapter->chan_offset));
 
-	if (!sme && (mode != MWIFIEX_BSS_MODE_IBSS)) {
-		BUG_ON(sme == NULL);
-		return ret;
-	}
-
 	ret = mwifiex_set_encode(priv, NULL, 0, 0, 1);	/* Disable keys */
 
-	if (!sme && privacy) {
-		/*
-		 * Keep MWIFIEX_ENCRYPTION_MODE_WEP40 for now so that
-		 * the firmware can find a matching network from the
-		 * scan. cfg80211 doesnt not give us the encryption
-		 * mode at this stage so just setting it to wep here
-		 */
-		auth_type = MWIFIEX_AUTH_MODE_OPEN;
-		wpa_enabled = 0;
-		ret = mwifiex_set_auth(priv, MWIFIEX_ENCRYPTION_MODE_WEP104,
-							auth_type, wpa_enabled);
+	if (mode == MWIFIEX_BSS_MODE_IBSS) {
+		/* "privacy" is set only for ad-hoc mode */
+		if (privacy) {
+			/*
+			 * Keep MWIFIEX_ENCRYPTION_MODE_WEP104 for now so that
+			 * the firmware can find a matching network from the
+			 * scan. The cfg80211 does not give us the encryption
+			 * mode at this stage so just setting it to WEP here.
+			 */
+			wpa_enabled = 0;
+			auth_type = MWIFIEX_AUTH_MODE_OPEN;
+			ret = mwifiex_set_auth(priv,
+						MWIFIEX_ENCRYPTION_MODE_WEP104,
+						auth_type, wpa_enabled);
+		}
+
 		goto done;
 	}
 
+	/* Now handle infra mode. "sme" is valid for infra mode only */
 	if (sme->auth_type == NL80211_AUTHTYPE_AUTOMATIC
 			|| sme->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
 		auth_type = MWIFIEX_AUTH_MODE_OPEN;
-- 
1.7.0.2

--
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