qcacld-3.0: Acquire mutex before accessing tdls context
qcacld-2.0 to qcacld-3.0 propagation 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 wlan_hdd_ tdls_set_rssi() and __wlan_hdd_cfg80211_tdls_mgmt() before calling wlan_hdd_tdls_find_peer(). Change-Id: I1cedeff6f42854a66b4c878dd8d4ecf345ae875f CRs-Fixed: 1108952
This commit is contained in:
@@ -1377,14 +1377,21 @@ int wlan_hdd_tdls_set_rssi(hdd_adapter_t *pAdapter, const uint8_t *mac,
|
|||||||
int8_t rxRssi)
|
int8_t rxRssi)
|
||||||
{
|
{
|
||||||
hddTdlsPeer_t *curr_peer;
|
hddTdlsPeer_t *curr_peer;
|
||||||
|
hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
|
||||||
|
|
||||||
curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, true);
|
if (0 != (wlan_hdd_validate_context(hdd_ctx)))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
mutex_lock(&hdd_ctx->tdls_lock);
|
||||||
|
curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, false);
|
||||||
if (curr_peer == NULL) {
|
if (curr_peer == NULL) {
|
||||||
|
mutex_unlock(&hdd_ctx->tdls_lock);
|
||||||
hdd_err("curr_peer is NULL");
|
hdd_err("curr_peer is NULL");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
curr_peer->rssi = rxRssi;
|
curr_peer->rssi = rxRssi;
|
||||||
|
mutex_unlock(&hdd_ctx->tdls_lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -4120,17 +4127,24 @@ static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
|
|||||||
*/
|
*/
|
||||||
} else {
|
} else {
|
||||||
hddTdlsPeer_t *pTdlsPeer;
|
hddTdlsPeer_t *pTdlsPeer;
|
||||||
|
mutex_lock(&pHddCtx->tdls_lock);
|
||||||
pTdlsPeer =
|
pTdlsPeer =
|
||||||
wlan_hdd_tdls_find_peer(pAdapter, peer, true);
|
wlan_hdd_tdls_find_peer(pAdapter, peer, false);
|
||||||
if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) {
|
if (pTdlsPeer) {
|
||||||
QDF_TRACE(QDF_MODULE_ID_HDD,
|
if (TDLS_IS_CONNECTED(pTdlsPeer)) {
|
||||||
QDF_TRACE_LEVEL_ERROR,
|
mutex_unlock(&pHddCtx->tdls_lock);
|
||||||
"%s:" MAC_ADDRESS_STR
|
QDF_TRACE(QDF_MODULE_ID_HDD,
|
||||||
" already connected. action %d declined.",
|
QDF_TRACE_LEVEL_ERROR,
|
||||||
__func__, MAC_ADDR_ARRAY(peer),
|
"%s:" MAC_ADDRESS_STR
|
||||||
action_code);
|
" already connected."
|
||||||
return -EPERM;
|
" action %d declined.",
|
||||||
|
__func__,
|
||||||
|
MAC_ADDR_ARRAY(peer),
|
||||||
|
action_code);
|
||||||
|
return -EPERM;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
mutex_unlock(&pHddCtx->tdls_lock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qdf_mem_copy(peerMac, peer, 6);
|
qdf_mem_copy(peerMac, peer, 6);
|
||||||
@@ -4144,20 +4158,30 @@ static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
|
|||||||
if (SIR_MAC_TDLS_TEARDOWN == action_code) {
|
if (SIR_MAC_TDLS_TEARDOWN == action_code) {
|
||||||
|
|
||||||
hddTdlsPeer_t *pTdlsPeer;
|
hddTdlsPeer_t *pTdlsPeer;
|
||||||
pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, true);
|
mutex_lock(&pHddCtx->tdls_lock);
|
||||||
|
pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, false);
|
||||||
|
if (!pTdlsPeer) {
|
||||||
|
mutex_unlock(&pHddCtx->tdls_lock);
|
||||||
|
QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
|
||||||
|
"%s: " MAC_ADDRESS_STR " peer doesn't exist",
|
||||||
|
__func__, MAC_ADDR_ARRAY(peer));
|
||||||
|
return -EPERM;
|
||||||
|
}
|
||||||
|
|
||||||
if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
|
if (TDLS_IS_CONNECTED(pTdlsPeer))
|
||||||
responder = pTdlsPeer->is_responder;
|
responder = pTdlsPeer->is_responder;
|
||||||
else {
|
else {
|
||||||
QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
|
QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
|
||||||
"%s: " MAC_ADDRESS_STR
|
"%s: " MAC_ADDRESS_STR
|
||||||
" peer doesn't exist or not connected %d dialog_token %d status %d, len = %zu",
|
" peer doesn't exist or not connected %d "
|
||||||
|
"dialog_token %d status %d, len = %zu",
|
||||||
__func__, MAC_ADDR_ARRAY(peer),
|
__func__, MAC_ADDR_ARRAY(peer),
|
||||||
(NULL ==
|
pTdlsPeer->link_status,
|
||||||
pTdlsPeer) ? -1 : pTdlsPeer->link_status,
|
|
||||||
dialog_token, status_code, len);
|
dialog_token, status_code, len);
|
||||||
|
mutex_unlock(&pHddCtx->tdls_lock);
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
|
mutex_unlock(&pHddCtx->tdls_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For explicit trigger of DIS_REQ come out of BMPS for
|
/* For explicit trigger of DIS_REQ come out of BMPS for
|
||||||
|
Reference in New Issue
Block a user