summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNitesh Shah <niteshs@codeaurora.org>2017-01-09 18:53:54 +0530
committerGerrit - the friendly Code Review server <code-review@localhost>2017-02-02 04:28:37 -0800
commit3c0f4617cabc60bd0777b57a6ef539a94f75db9e (patch)
tree716c6bfd885fb2919b27b2a98e936df32e4c2643
parent304b958e088b889385349a0667c5d26e0fa8175e (diff)
qcacld-2.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 wlan_hdd_tdls_reset _peer(), wlan_hdd_tdls_set_sta_id() and wlan_hdd_tdls_ increment_pkt_count(). Change-Id: I5950c411ca48186d6cb7cbd5a4acd688db1a0cba CRs-Fixed: 1108994
-rw-r--r--CORE/HDD/src/wlan_hdd_tdls.c65
1 files changed, 51 insertions, 14 deletions
diff --git a/CORE/HDD/src/wlan_hdd_tdls.c b/CORE/HDD/src/wlan_hdd_tdls.c
index d1321a054e43..dc3171c4cc89 100644
--- a/CORE/HDD/src/wlan_hdd_tdls.c
+++ b/CORE/HDD/src/wlan_hdd_tdls.c
@@ -1464,16 +1464,27 @@ int wlan_hdd_tdls_increment_pkt_count(hdd_adapter_t *pAdapter, const u8 *mac,
u8 tx)
{
hddTdlsPeer_t *curr_peer;
- hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
+ hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
+ int status = 0;
- if (eTDLS_SUPPORT_ENABLED != pHddCtx->tdls_mode &&
- eTDLS_SUPPORT_EXTERNAL_CONTROL != pHddCtx->tdls_mode)
- return -1;
+ if (0 != (wlan_hdd_validate_context(hdd_ctx))) {
+ status = -EINVAL;
+ goto ret_status;
+ }
- curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac, TRUE);
+ if (eTDLS_SUPPORT_ENABLED != hdd_ctx->tdls_mode &&
+ eTDLS_SUPPORT_EXTERNAL_CONTROL != hdd_ctx->tdls_mode) {
+ status = -EINVAL;
+ goto ret_status;
+ }
+
+ mutex_lock(&hdd_ctx->tdls_lock);
+
+ curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac, FALSE);
if (curr_peer == NULL) {
hddLog(LOG1, FL("curr_peer is NULL"));
- return -1;
+ status = -EINVAL;
+ goto rel_lock;
}
if (tx)
@@ -1481,7 +1492,10 @@ int wlan_hdd_tdls_increment_pkt_count(hdd_adapter_t *pAdapter, const u8 *mac,
else
curr_peer->rx_pkt++;
- return 0;
+rel_lock:
+ mutex_unlock(&hdd_ctx->tdls_lock);
+ret_status:
+ return status;
}
static int wlan_hdd_tdls_check_config(tdls_config_params_t *config)
@@ -2015,18 +2029,30 @@ void wlan_hdd_update_tdls_info(hdd_adapter_t *adapter, bool tdls_prohibited,
int wlan_hdd_tdls_set_sta_id(hdd_adapter_t *pAdapter, const u8 *mac, u8 staId)
{
hddTdlsPeer_t *curr_peer;
+ hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
+ int status = 0;
+
+ if (0 != (wlan_hdd_validate_context(hdd_ctx))) {
+ status = -EINVAL;
+ goto ret_status;
+ }
- curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac, TRUE);
+ mutex_lock(&hdd_ctx->tdls_lock);
+ curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac, FALSE);
if (curr_peer == NULL)
{
VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
FL("curr_peer is NULL"));
- return -1;
+ status = -EINVAL;
+ goto rel_lock;
}
curr_peer->staId = staId;
- return 0;
+rel_lock:
+ mutex_unlock(&hdd_ctx->tdls_lock);
+ret_status:
+ return status;
}
int wlan_hdd_tdls_set_extctrl_param(hdd_adapter_t *pAdapter, const uint8_t *mac,
@@ -2202,15 +2228,23 @@ int wlan_hdd_tdls_reset_peer(hdd_adapter_t *pAdapter, const u8 *mac)
{
hdd_context_t *pHddCtx;
hddTdlsPeer_t *curr_peer;
+ int status = 0;
pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
- curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac, TRUE);
+ if (0 != (wlan_hdd_validate_context(pHddCtx))) {
+ status = -EINVAL;
+ goto ret_status;
+ }
+
+ mutex_lock(&pHddCtx->tdls_lock);
+ curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac, FALSE);
if (curr_peer == NULL)
{
VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
FL("curr_peer is NULL"));
- return -1;
+ status = -EINVAL;
+ goto rel_lock;
}
/*
@@ -2231,10 +2265,13 @@ int wlan_hdd_tdls_reset_peer(hdd_adapter_t *pAdapter, const u8 *mac)
wlan_hdd_tdls_set_peer_link_status(curr_peer,
eTDLS_LINK_IDLE,
eTDLS_LINK_UNSPECIFIED,
- TRUE);
+ FALSE);
curr_peer->staId = 0;
- return 0;
+rel_lock:
+ mutex_unlock(&pHddCtx->tdls_lock);
+ret_status:
+ return status;
}
tANI_U16 wlan_hdd_tdlsConnectedPeers(hdd_adapter_t *pAdapter)