From 69e3310fc692dc327efac11bc01cb4e4e8ab1bae Mon Sep 17 00:00:00 2001 From: Naveen Rawat Date: Mon, 20 Jul 2015 19:17:45 -0700 Subject: qcacld-2.0: Avoid race condition between change_iface and connect from user In hdd_stop_adapter, issue disconnect is getting called only if adapter state is connected. This causes race condition between change_iface and connect req from user, since when hdd_stop_adapter is called at that time adapter was still connecting and not connected. This leads to sme close session without disconnecting current (connecting) session. This would then messup whole lim state machine. To fix this, in function hdd_stop_adapter code should check if state is connecting or connected and then issue disconnect before proceeding further. Change-Id: I29f325d2784534c1ad5641a4cf08ddd316f9e8a0 CRs-Fixed: 873342 --- CORE/HDD/inc/wlan_hdd_assoc.h | 1 + CORE/HDD/src/wlan_hdd_assoc.c | 6 ++++++ CORE/HDD/src/wlan_hdd_main.c | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CORE/HDD/inc/wlan_hdd_assoc.h b/CORE/HDD/inc/wlan_hdd_assoc.h index 2bf38aa511d6..d0cf936973f0 100644 --- a/CORE/HDD/inc/wlan_hdd_assoc.h +++ b/CORE/HDD/inc/wlan_hdd_assoc.h @@ -131,6 +131,7 @@ typedef enum }ePeerStatus; extern v_BOOL_t hdd_connIsConnected( hdd_station_ctx_t *pHddStaCtx ); +extern bool hdd_is_connecting(hdd_station_ctx_t *hdd_sta_ctx); eCsrBand hdd_connGetConnectedBand( hdd_station_ctx_t *pHddStaCtx ); extern eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, v_U32_t roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult ); diff --git a/CORE/HDD/src/wlan_hdd_assoc.c b/CORE/HDD/src/wlan_hdd_assoc.c index 27982f0315f0..419c420922da 100644 --- a/CORE/HDD/src/wlan_hdd_assoc.c +++ b/CORE/HDD/src/wlan_hdd_assoc.c @@ -181,6 +181,12 @@ v_BOOL_t hdd_connIsConnected( hdd_station_ctx_t *pHddStaCtx ) return( hdd_connGetConnectionState( pHddStaCtx, NULL ) ); } +bool hdd_is_connecting(hdd_station_ctx_t *hdd_sta_ctx) +{ + return (hdd_sta_ctx->conn_info.connState == + eConnectionState_Connecting); +} + eCsrBand hdd_connGetConnectedBand( hdd_station_ctx_t *pHddStaCtx ) { v_U8_t staChannel = 0; diff --git a/CORE/HDD/src/wlan_hdd_main.c b/CORE/HDD/src/wlan_hdd_main.c index f91e1210b3b9..8dc58f33ebb4 100755 --- a/CORE/HDD/src/wlan_hdd_main.c +++ b/CORE/HDD/src/wlan_hdd_main.c @@ -9143,7 +9143,8 @@ VOS_STATUS hdd_stop_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, case WLAN_HDD_INFRA_STATION: case WLAN_HDD_P2P_CLIENT: case WLAN_HDD_P2P_DEVICE: - if( hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR( pAdapter )) ) + if (hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) || + hdd_is_connecting(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) { if (pWextState->roamProfile.BSSType == eCSR_BSS_TYPE_START_IBSS) halStatus = sme_RoamDisconnect(pHddCtx->hHal, -- cgit v1.2.3