diff options
| author | Nitesh Shah <niteshs@codeaurora.org> | 2017-01-31 16:40:16 +0530 |
|---|---|---|
| committer | qcabuildsw <qcabuildsw@localhost> | 2017-03-03 16:34:56 -0800 |
| commit | a00e08accafebf3d0606d7f06df1a1950e388672 (patch) | |
| tree | 0f9a58801837de61f61289910ed5b511412a92dc | |
| parent | e0c24475aed755cf099e2c849b2f2d9e6bb884bf (diff) | |
qcacld-3.0: Acquire mutex before accessing tdls context
peer_list is a parameter for tdls_ctx, so every access to
peer_list should be protected with mutex lock.
This change refactors the code for function wlan_hdd_tdls
_idle_handler(), hdd_tdls_connection_tracker_update() and
hdd_roam_tdls_status_update_handler().
Change-Id: I75dc17b581b0c5ef12cbc9203d679a5ea175c752
CRs-Fixed: 1106172
| -rw-r--r-- | core/hdd/src/wlan_hdd_assoc.c | 65 | ||||
| -rw-r--r-- | core/hdd/src/wlan_hdd_tdls.c | 6 |
2 files changed, 51 insertions, 20 deletions
diff --git a/core/hdd/src/wlan_hdd_assoc.c b/core/hdd/src/wlan_hdd_assoc.c index adaae0a44900..4d4b3b08daa3 100644 --- a/core/hdd/src/wlan_hdd_assoc.c +++ b/core/hdd/src/wlan_hdd_assoc.c @@ -3505,15 +3505,13 @@ static QDF_STATUS hdd_tdls_connection_tracker_update(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); curr_peer = wlan_hdd_tdls_find_peer(adapter, - roam_info->peerMac.bytes, true); + roam_info->peerMac.bytes, false); if (!curr_peer) { hdd_err("curr_peer is null"); return QDF_STATUS_E_FAILURE; } - mutex_lock(&hdd_ctx->tdls_lock); - if (eTDLS_LINK_CONNECTED == curr_peer->link_status) { hdd_err("Received CONNECTION_TRACKER_NOTIFICATION " @@ -3544,8 +3542,6 @@ static QDF_STATUS hdd_tdls_connection_tracker_update(hdd_adapter_t *adapter, roam_info->reasonCode); } - mutex_unlock(&hdd_ctx->tdls_lock); - return QDF_STATUS_SUCCESS; } @@ -3574,7 +3570,7 @@ hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter, eCsrRoamResult roamResult) { hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); - tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); + tdlsCtx_t *pHddTdlsCtx; tSmeTdlsPeerStateParams smeTdlsPeerStateParams; QDF_STATUS status = QDF_STATUS_E_FAILURE; uint8_t staIdx; @@ -3603,12 +3599,6 @@ hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter, "TDLS_SHOULD_PEER_DISCONNECTED" : "UNKNOWN", pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes)); - if (!pHddTdlsCtx) { - hdd_info("TDLS ctx is null, ignore roamResult (%d)", - roamResult); - return status; - } - switch (roamResult) { case eCSR_ROAM_RESULT_ADD_TDLS_PEER: { @@ -3766,13 +3756,17 @@ hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter, hdd_err("Sending teardown to supplicant with reason code %u", pRoamInfo->reasonCode); + mutex_lock(&pHddCtx->tdls_lock); curr_peer = wlan_hdd_tdls_find_peer(pAdapter, - pRoamInfo->peerMac.bytes, true); + pRoamInfo->peerMac.bytes, + false); wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, - pRoamInfo->reasonCode, true); + pRoamInfo->reasonCode, + false); hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_BSS_DISCONNECT, curr_peer->peerMac); + mutex_unlock(&pHddCtx->tdls_lock); status = QDF_STATUS_SUCCESS; break; } @@ -3923,9 +3917,20 @@ hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter, case eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN: { + mutex_lock(&pHddCtx->tdls_lock); + pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); + if (!pHddTdlsCtx) { + mutex_unlock(&pHddCtx->tdls_lock); + hdd_info("TDLS ctx is null, ignore roamResult (%d)", + roamResult); + status = QDF_STATUS_E_FAILURE; + break; + } + curr_peer = wlan_hdd_tdls_find_peer(pAdapter, - pRoamInfo->peerMac.bytes, true); + pRoamInfo->peerMac.bytes, + false); if (!curr_peer) { hdd_info("curr_peer is null"); status = QDF_STATUS_E_FAILURE; @@ -3956,7 +3961,7 @@ hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter, wlan_hdd_tdls_indicate_teardown (pHddTdlsCtx->pAdapter, curr_peer, - reason, true); + reason, false); hdd_send_wlan_tdls_teardown_event( eTDLS_TEARDOWN_BSS_DISCONNECT, curr_peer->peerMac); @@ -3966,14 +3971,26 @@ hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter, } status = QDF_STATUS_SUCCESS; } + mutex_unlock(&pHddCtx->tdls_lock); break; } case eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED: { + mutex_lock(&pHddCtx->tdls_lock); + pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); + if (!pHddTdlsCtx) { + mutex_unlock(&pHddCtx->tdls_lock); + hdd_info("TDLS ctx is null, ignore roamResult (%d)", + roamResult); + status = QDF_STATUS_E_FAILURE; + break; + } + curr_peer = wlan_hdd_tdls_find_peer(pAdapter, - pRoamInfo->peerMac.bytes, true); + pRoamInfo->peerMac.bytes, + false); if (!curr_peer) { hdd_info("curr_peer is null"); status = QDF_STATUS_E_FAILURE; @@ -4003,7 +4020,7 @@ hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter, wlan_hdd_tdls_indicate_teardown (pHddTdlsCtx->pAdapter, curr_peer, - reason, true); + reason, false); hdd_send_wlan_tdls_teardown_event( eTDLS_TEARDOWN_BSS_DISCONNECT, curr_peer->peerMac); @@ -4013,13 +4030,25 @@ hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter, } status = QDF_STATUS_SUCCESS; } + mutex_unlock(&pHddCtx->tdls_lock); break; } case eCSR_ROAM_RESULT_TDLS_CONNECTION_TRACKER_NOTIFICATION: + mutex_lock(&pHddCtx->tdls_lock); + pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); + if (!pHddTdlsCtx) { + mutex_unlock(&pHddCtx->tdls_lock); + hdd_info("TDLS ctx is null, ignore roamResult (%d)", + roamResult); + status = QDF_STATUS_E_FAILURE; + break; + } + status = hdd_tdls_connection_tracker_update(pAdapter, pRoamInfo, pHddTdlsCtx); + mutex_unlock(&pHddCtx->tdls_lock); break; default: diff --git a/core/hdd/src/wlan_hdd_tdls.c b/core/hdd/src/wlan_hdd_tdls.c index 9784e53667ed..8d7fb445d79a 100644 --- a/core/hdd/src/wlan_hdd_tdls.c +++ b/core/hdd/src/wlan_hdd_tdls.c @@ -5735,8 +5735,9 @@ static void wlan_hdd_tdls_idle_handler(void *user_data) return; } + mutex_lock(&hdd_ctx->tdls_lock); curr_peer = wlan_hdd_tdls_find_peer(adapter, - (u8 *) &tdls_info->peerMac.bytes[0], true); + (u8 *) &tdls_info->peerMac.bytes[0], false); if (NULL == curr_peer) { hdd_err("Invalid tdls idle timer expired"); @@ -5773,9 +5774,10 @@ static void wlan_hdd_tdls_idle_handler(void *user_data) wlan_hdd_tdls_indicate_teardown(curr_peer->pHddTdlsCtx->pAdapter, curr_peer, eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON, - true); + false); } error_idle_return: + mutex_unlock(&hdd_ctx->tdls_lock); return; } |
