summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNitesh Shah <niteshs@codeaurora.org>2017-01-30 18:47:24 +0530
committerqcabuildsw <qcabuildsw@localhost>2017-03-03 16:34:48 -0800
commit4e531f3a58eea25ad1bfd3338cbb9f1a10b0e652 (patch)
tree634d2562bd44de34cb2c3b7c24f592654a78b6b8
parentf474fc4de458f997d00a6993d077424cefb4a88d (diff)
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_reset _peer() and wlan_hdd_tdls_set_sta_id(). Change-Id: I5950c411ca48186d6cb7cbd5a4acd688db1a0cba CRs-Fixed: 1108994
-rw-r--r--core/hdd/src/wlan_hdd_tdls.c39
1 files changed, 30 insertions, 9 deletions
diff --git a/core/hdd/src/wlan_hdd_tdls.c b/core/hdd/src/wlan_hdd_tdls.c
index 6b16de9afb75..cf53d91d3703 100644
--- a/core/hdd/src/wlan_hdd_tdls.c
+++ b/core/hdd/src/wlan_hdd_tdls.c
@@ -2147,16 +2147,27 @@ int wlan_hdd_tdls_set_sta_id(hdd_adapter_t *pAdapter, const uint8_t *mac,
uint8_t 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) {
hdd_err("curr_peer is NULL");
- return -EINVAL;
+ status = -EINVAL;
+ goto rel_lock;
}
curr_peer->staId = staId;
-
- return 0;
+rel_lock:
+ mutex_unlock(&hdd_ctx->tdls_lock);
+ret_status:
+ return status;
}
/**
@@ -2356,13 +2367,21 @@ int wlan_hdd_tdls_reset_peer(hdd_adapter_t *pAdapter, const uint8_t *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) {
hdd_err("curr_peer is NULL");
- return -EINVAL;
+ status = -EINVAL;
+ goto rel_lock;
}
/*
@@ -2384,10 +2403,12 @@ int wlan_hdd_tdls_reset_peer(hdd_adapter_t *pAdapter, const uint8_t *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;
}
/**