diff --git a/core/hdd/src/wlan_hdd_ioctl.c b/core/hdd/src/wlan_hdd_ioctl.c index 004b1085d28f..38e5f882b73e 100644 --- a/core/hdd/src/wlan_hdd_ioctl.c +++ b/core/hdd/src/wlan_hdd_ioctl.c @@ -710,8 +710,18 @@ int hdd_reassoc(struct hdd_adapter *adapter, const uint8_t *bssid, sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); - /* if not associated, no need to proceed with reassoc */ - if (eConnectionState_Associated != sta_ctx->conn_info.connState) { + /* + * pHddStaCtx->conn_info.connState is set to disconnected only + * after the disconnect done indication from SME. If the SME is + * in the process of disconnecting, the SME Connection state is + * set to disconnected and the pHddStaCtx->conn_info.connState + * will still be associated till the disconnect is done. + * So check both the HDD state and SME state here. + * If not associated, no need to proceed with reassoc + */ + if ((eConnectionState_Associated != sta_ctx->conn_info.connState) || + (!sme_is_conn_state_connected(hdd_ctx->mac_handle, + adapter->session_id))) { hdd_warn("Not associated"); ret = -EINVAL; goto exit; diff --git a/core/sme/inc/sme_api.h b/core/sme/inc/sme_api.h index 454633f8eeea..ffea233ea0a2 100644 --- a/core/sme/inc/sme_api.h +++ b/core/sme/inc/sme_api.h @@ -2265,6 +2265,18 @@ static inline QDF_STATUS sme_set_he_bss_color(tHalHandle hal, } #endif +/** + * sme_is_conn_state_connected() -- check if SME connection state is connected + * @hal: global hal handle + * @session_id: current Session Id + * + * This API checks if the current SME connection state is connected for the + * given session id. + * + * Return: True if connected, false if any other state. + */ +bool sme_is_conn_state_connected(mac_handle_t hal, uint8_t session_id); + /** * sme_scan_get_result_for_bssid - gets the scan result from scan cache for the * bssid specified diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c index a3ca045a50e4..0798d8e8a9cd 100644 --- a/core/sme/src/common/sme_api.c +++ b/core/sme/src/common/sme_api.c @@ -15990,6 +15990,13 @@ static bool sme_get_status_for_candidate(tHalHandle hal, return false; } +bool sme_is_conn_state_connected(mac_handle_t hal, uint8_t session_id) +{ + tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal); + + return csr_is_conn_state_connected(mac_ctx, session_id); +} + /** * wlan_hdd_get_bss_transition_status() - get bss transition status all cadidates * @adapter : Pointer to adapter