diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index 20f73e649a5a..14588985eff6 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -8949,10 +8949,15 @@ int wlan_hdd_disconnect(hdd_adapter_t *pAdapter, u16 reason) status = sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, reason); + /* + * Wait here instead of returning directly, this will block the next + * connect command and allow processing of the scan for ssid and + * the previous connect command in CSR. Else we might hit some + * race conditions leading to SME and HDD out of sync. + */ if (CDF_STATUS_CMD_NOT_QUEUED == status) { hddLog(LOG1, FL("status = %d, already disconnected"), (int)status); - goto disconnected; } else if (0 != status) { hddLog(LOGE, FL("csr_roam_disconnect failure, returned %d"), @@ -9130,7 +9135,6 @@ static int __wlan_hdd_cfg80211_disconnect(struct wiphy *wiphy, hddLog(LOG1, FL("convert to internal reason %d to reasonCode %d"), reason, reasonCode); - pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; pScanInfo = &pAdapter->scan_info; if (pScanInfo->mScanPending) { hddLog(LOG1, diff --git a/core/sme/src/csr/csr_api_roam.c b/core/sme/src/csr/csr_api_roam.c index b7a9aefb3711..b5af6635e9bc 100644 --- a/core/sme/src/csr/csr_api_roam.c +++ b/core/sme/src/csr/csr_api_roam.c @@ -6644,10 +6644,9 @@ static bool csr_roam_process_results(tpAniSirGlobal mac_ctx, tSmeCmd *cmd, roam_info.pbFrames = session->connectedInfo.pbFrames; roam_info.staId = session->connectedInfo.staId; roam_info.u.pConnectedProfile = &session->connectedProfile; - if (0 == roam_info.staId) { + if (0 == roam_info.staId) CDF_ASSERT(0); - return false; - } + session->bRefAssocStartCnt--; csr_roam_call_callback(mac_ctx, session_id, &roam_info, cmd->u.roamCmd.roamId, @@ -7196,6 +7195,19 @@ CDF_STATUS csr_roam_connect(tpAniSirGlobal pMac, uint32_t sessionId, &pSession->connectedProfile.SSID, &pProfile->SSIDs)) csr_roam_issue_disassociate_cmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED); + /* + * If roamSession.connectState is disconnecting that mean + * disconnect was received with scan for ssid in progress + * and dropped. This state will ensure that connect will + * not be issued from scan for ssid completion. Thus + * if this fresh connect also issue scan for ssid the connect + * command will be dropped assuming disconnect is in progress. + * Thus reset connectState here + */ + if (eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTING == + pMac->roam.roamSession[sessionId].connectState) + pMac->roam.roamSession[sessionId].connectState = + eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED; #ifdef FEATURE_WLAN_BTAMP_UT_RF pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT; #endif