diff options
| author | Nitesh Shah <niteshs@codeaurora.org> | 2017-01-31 17:56:28 +0530 |
|---|---|---|
| committer | qcabuildsw <qcabuildsw@localhost> | 2017-03-03 16:35:01 -0800 |
| commit | 43236999edbb1f3d97f4a35d79fb7a735c2cf2ab (patch) | |
| tree | 8cf4957514dc125110a6f33b44bb28d69f3823b0 | |
| parent | 9c73266c46e0a487e621a951f14db93b8ffcda17 (diff) | |
qcacld-3.0: Acquire mutex before accessing tdls function
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
_indicate_teardown() by removing the need for mutex lock
inside the function, and refactors the calling functions.
Change-Id: I5a0da34b0db78a88a99046bf2ee007b50d6ce5c4
CRs-Fixed: 1106305
| -rw-r--r-- | core/hdd/inc/wlan_hdd_tdls.h | 2 | ||||
| -rw-r--r-- | core/hdd/src/wlan_hdd_assoc.c | 7 | ||||
| -rw-r--r-- | core/hdd/src/wlan_hdd_tdls.c | 32 |
3 files changed, 15 insertions, 26 deletions
diff --git a/core/hdd/inc/wlan_hdd_tdls.h b/core/hdd/inc/wlan_hdd_tdls.h index 837d7a41ace7..7fed1ef50092 100644 --- a/core/hdd/inc/wlan_hdd_tdls.h +++ b/core/hdd/inc/wlan_hdd_tdls.h @@ -611,7 +611,7 @@ void wlan_hdd_tdls_timer_restart(hdd_adapter_t *pAdapter, uint32_t expirationTime); void wlan_hdd_tdls_indicate_teardown(hdd_adapter_t *pAdapter, hddTdlsPeer_t *curr_peer, - uint16_t reason, bool need_lock); + uint16_t reason); void wlan_hdd_tdls_implicit_send_discovery_request(tdlsCtx_t *hdd_tdls_ctx); diff --git a/core/hdd/src/wlan_hdd_assoc.c b/core/hdd/src/wlan_hdd_assoc.c index 4d4b3b08daa3..17979a4a5b7a 100644 --- a/core/hdd/src/wlan_hdd_assoc.c +++ b/core/hdd/src/wlan_hdd_assoc.c @@ -3762,8 +3762,7 @@ hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter, pRoamInfo->peerMac.bytes, false); wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, - pRoamInfo->reasonCode, - false); + pRoamInfo->reasonCode); hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_BSS_DISCONNECT, curr_peer->peerMac); mutex_unlock(&pHddCtx->tdls_lock); @@ -3961,7 +3960,7 @@ hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter, wlan_hdd_tdls_indicate_teardown (pHddTdlsCtx->pAdapter, curr_peer, - reason, false); + reason); hdd_send_wlan_tdls_teardown_event( eTDLS_TEARDOWN_BSS_DISCONNECT, curr_peer->peerMac); @@ -4020,7 +4019,7 @@ hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter, wlan_hdd_tdls_indicate_teardown (pHddTdlsCtx->pAdapter, curr_peer, - reason, false); + reason); hdd_send_wlan_tdls_teardown_event( eTDLS_TEARDOWN_BSS_DISCONNECT, curr_peer->peerMac); diff --git a/core/hdd/src/wlan_hdd_tdls.c b/core/hdd/src/wlan_hdd_tdls.c index f9fe95aa2162..8064c307f59e 100644 --- a/core/hdd/src/wlan_hdd_tdls.c +++ b/core/hdd/src/wlan_hdd_tdls.c @@ -271,8 +271,7 @@ void wlan_hdd_tdls_disable_offchan_and_teardown_links(hdd_context_t *hddctx) wlan_hdd_tdls_indicate_teardown( curr_peer->pHddTdlsCtx->pAdapter, curr_peer, - eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON, - false); + eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON); hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_CONCURRENCY, curr_peer->peerMac); mutex_unlock(&hddctx->tdls_lock); @@ -2961,10 +2960,10 @@ int wlan_hdd_tdls_scan_callback(hdd_adapter_t *pAdapter, struct wiphy *wiphy, return 1; } + mutex_lock(&pHddCtx->tdls_lock); for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta; staIdx++) { if (pHddCtx->tdlsConnInfo[staIdx].staId) { - mutex_lock(&pHddCtx->tdls_lock); curr_peer = wlan_hdd_tdls_find_all_peer(pHddCtx, pHddCtx-> @@ -2978,7 +2977,6 @@ int wlan_hdd_tdls_scan_callback(hdd_adapter_t *pAdapter, struct wiphy *wiphy, if (!(curr_peer->isBufSta)) allPeersBufStas = 0; } - mutex_unlock(&pHddCtx->tdls_lock); } } @@ -2986,6 +2984,7 @@ int wlan_hdd_tdls_scan_callback(hdd_adapter_t *pAdapter, struct wiphy *wiphy, connectedTdlsPeers) && (pHddCtx->config->fEnableTDLSSleepSta) && (allPeersBufStas)) { + mutex_unlock(&pHddCtx->tdls_lock); /* All connected peers bufStas and we can be sleepSta * so allow scan */ @@ -3000,12 +2999,12 @@ int wlan_hdd_tdls_scan_callback(hdd_adapter_t *pAdapter, struct wiphy *wiphy, wlan_hdd_tdls_indicate_teardown (connectedPeerList[i]->pHddTdlsCtx-> pAdapter, connectedPeerList[i], - eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON, - true); + eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON); hdd_send_wlan_tdls_teardown_event( eTDLS_TEARDOWN_SCAN, connectedPeerList[i]->peerMac); } + mutex_unlock(&pHddCtx->tdls_lock); } /* schedule scan */ delay = @@ -3105,13 +3104,11 @@ void wlan_hdd_tdls_timer_restart(hdd_adapter_t *pAdapter, * @pAdapter: HDD adapter * @curr_peer: peer tdls teardown happened * @reason: teardown reason - * @need_lock: mutex lock for wlan_hdd_tdls_set_peer_link_status() * * Return: Void */ void wlan_hdd_tdls_indicate_teardown(hdd_adapter_t *pAdapter, - hddTdlsPeer_t *curr_peer, uint16_t reason, - bool need_lock) + hddTdlsPeer_t *curr_peer, uint16_t reason) { if ((NULL == pAdapter || WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) || (NULL == curr_peer)) { @@ -3127,7 +3124,7 @@ void wlan_hdd_tdls_indicate_teardown(hdd_adapter_t *pAdapter, wlan_hdd_tdls_set_peer_link_status(curr_peer, eTDLS_LINK_TEARING, eTDLS_LINK_UNSPECIFIED, - need_lock); + false); hdd_info("Teardown reason %d", reason); cfg80211_tdls_oper_request(pAdapter->dev, curr_peer->peerMac, @@ -4656,8 +4653,7 @@ int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter, goto rel_lock; } else { wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer, - eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON, - false); + eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON); hdd_send_wlan_tdls_teardown_event( eTDLS_TEARDOWN_EXT_CTRL, pTdlsPeer->peerMac); @@ -5781,8 +5777,7 @@ static void wlan_hdd_tdls_idle_handler(void *user_data) " down", MAC_ADDR_ARRAY(curr_peer->peerMac)); wlan_hdd_tdls_indicate_teardown(curr_peer->pHddTdlsCtx->pAdapter, curr_peer, - eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON, - false); + eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON); } error_idle_return: mutex_unlock(&hdd_ctx->tdls_lock); @@ -5841,13 +5836,9 @@ static void tdls_ct_process_connected_link(hddTdlsPeer_t *curr_peer, (int32_t)hdd_tdls_ctx->threshold_config.rssi_teardown_threshold) { hdd_warn("Tear down - low RSSI: " MAC_ADDRESS_STR "!", MAC_ADDR_ARRAY(curr_peer->peerMac)); - /* unlock the mutex here, it may used in caller function */ - mutex_unlock(&hdd_ctx->tdls_lock); wlan_hdd_tdls_indicate_teardown(hdd_tdls_ctx->pAdapter, curr_peer, - eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON, - true); - mutex_lock(&hdd_ctx->tdls_lock); + eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON); return; } @@ -6158,8 +6149,7 @@ static int wlan_hdd_tdls_teardown_links(hdd_context_t *hddctx, wlan_hdd_tdls_indicate_teardown( curr_peer->pHddTdlsCtx->pAdapter, curr_peer, - eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON, - false); + eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON); hddctx->tdls_teardown_peers_cnt++; mutex_unlock(&hddctx->tdls_lock); } |
