wlan: Protection of active session while disconnecting with spin lock.

[wpa_supplicant]wlan: wlan_hdd_disconnect: Set HDD connState to
                      eConnectionState_Disconnecting
[wpa_supplicant]wlan: wlan_hdd_decr_active_session:
                      No.# of active sessions for mode 2 = 0

If driver calls wlan_hdd_disconnect function and changes
connection state to eConnectionState_Disconnecting, at the
same time if thread context switch happens, hdd_DisConnectHandler
can also decrease active sessions.

[VosMCThread] wlan: ****eCSR_ROAM_DISASSOCIATED****
[VosMCThread] wlan: hdd_DisConnectHandler: Set HDD connState
                    to eConnectionState_Disconnecting from 2
[VosMCThread] wlan: hdd_connSetConnectionState:
                    ConnectionState Changed from oldState:2 to State:5
[VosMCThread] wlan: wlan_hdd_decr_active_session:
                    No.# of active sessions for mode 2 = 255

Here due to thread change, hdd_DisConnectHandler is being called
with connected state and driver will try to decrease active sessions
again.

Fix is to apply spinlock before getting connection state and
after setting connection state.

CRs-Fixed: 704001
Change-Id: I80dfac5324f6731896d5d2ae23d863173c85b455
diff --git a/CORE/HDD/src/wlan_hdd_cfg80211.c b/CORE/HDD/src/wlan_hdd_cfg80211.c
index a11ea25..10d7e36 100644
--- a/CORE/HDD/src/wlan_hdd_cfg80211.c
+++ b/CORE/HDD/src/wlan_hdd_cfg80211.c
@@ -10653,18 +10653,22 @@
 
     pHddCtx->isAmpAllowed = VOS_TRUE;
 
+    /* Need to apply spin lock before decreasing active sessions
+     * as there can be chance for double decrement if context switch
+     * Calls  hdd_DisConnectHandler.
+     */
+
+    spin_lock_bh(&pAdapter->lock_for_active_session);
     if (eConnectionState_Associated ==  pHddStaCtx->conn_info.connState)
     {
-        VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
-                   "%s: Set HDD connState to eConnectionState_Disconnecting",
-                   __func__);
         wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
     }
+    hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
+    spin_unlock_bh(&pAdapter->lock_for_active_session);
 
     VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
-                   "%s: Set HDD connState to eConnectionState_Disconnecting",
-                   __func__);
-    pHddStaCtx->conn_info.connState = eConnectionState_Disconnecting;
+                  FL( "Set HDD connState to eConnectionState_Disconnecting" ));
+
     INIT_COMPLETION(pAdapter->disconnect_comp_var);
 
     /*issue disconnect*/