Преглед изворни кода

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
Nitesh Shah пре 8 година
родитељ
комит
8816f57ef0
3 измењених фајлова са 15 додато и 26 уклоњено
  1. 1 1
      core/hdd/inc/wlan_hdd_tdls.h
  2. 3 4
      core/hdd/src/wlan_hdd_assoc.c
  3. 11 21
      core/hdd/src/wlan_hdd_tdls.c

+ 1 - 1
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);
 

+ 3 - 4
core/hdd/src/wlan_hdd_assoc.c

@@ -3858,8 +3858,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);
@@ -4056,7 +4055,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);
@@ -4115,7 +4114,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);

+ 11 - 21
core/hdd/src/wlan_hdd_tdls.c

@@ -272,8 +272,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);
@@ -2966,10 +2965,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->
@@ -2983,7 +2982,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);
 				}
 			}
 
@@ -2991,6 +2989,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
 				 */
@@ -3006,12 +3005,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 =
@@ -3111,13 +3110,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)) {
@@ -3133,7 +3130,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,
@@ -4671,8 +4668,7 @@ int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter,
 	}
 
 	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);
 	mutex_unlock(&pHddCtx->tdls_lock);
@@ -5794,8 +5790,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);
@@ -5854,13 +5849,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;
 	}
 
@@ -6172,8 +6163,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);
 	}