wlan: Avoid race codition for deauth/disassoc in SAP mode

1) When Deauth is triggered from host, SME sends the deauth req
to LIM and changes the mlm state to eLIM_MLM_WT_DEL_STA_RSP_STATE.
SME waits for the deauth rsp to free the active command roam.

2) During the above scenario, if FW sends the delete STA conext,
then LIM issues a disassoc request and change the disassoc trigger
to LINK MONITOR.
Due to disassoc trigger change, LIM sends the disassoc indication
instead of deauth resp that is required to clear the
active roam command.

Check is added, if deauth from host is already in progress, then
just drop the lim del sta context sent by FW.

Change-Id: I0664f6d6fc2eb004ad1fea6cd6e5afa28689776e
CRs-Fixed: 692647
diff --git a/CORE/MAC/src/pe/lim/limLinkMonitoringAlgo.c b/CORE/MAC/src/pe/lim/limLinkMonitoringAlgo.c
index c6ae10e..5fe3bc8 100644
--- a/CORE/MAC/src/pe/lim/limLinkMonitoringAlgo.c
+++ b/CORE/MAC/src/pe/lim/limLinkMonitoringAlgo.c
@@ -146,7 +146,27 @@
              {
                  PELOG1(limLog(pMac, LOG1, FL("SAP:lim Delete Station Context (staId: %d, assocId: %d) "),
                              pMsg->staId, pMsg->assocId);)
-                 limTriggerSTAdeletion(pMac, pStaDs, psessionEntry);
+                 /*
+                  * Check if Deauth/Disassoc is triggered from Host.
+                  * If mlmState is in some transient state then
+                  * don't trigger STA deletion to avoid the race
+                  * condition.
+                  */
+                  if ((pStaDs &&
+                      ((pStaDs->mlmStaContext.mlmState !=
+                        eLIM_MLM_LINK_ESTABLISHED_STATE) &&
+                       (pStaDs->mlmStaContext.mlmState !=
+                        eLIM_MLM_WT_ASSOC_CNF_STATE) &&
+                       (pStaDs->mlmStaContext.mlmState !=
+                        eLIM_MLM_ASSOCIATED_STATE))))
+                 {
+                     PELOGE(limLog(pMac, LOGE, FL("SAP:received Del STA context in some transit state(staId: %d, assocId: %d)"),
+                            pMsg->staId, pMsg->assocId);)
+                     vos_mem_free(pMsg);
+                     return;
+                 }
+                 else
+                     limTriggerSTAdeletion(pMac, pStaDs, psessionEntry);
              }
              else
              {