qcacld-3.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 function __wlan_hdd _cfg80211_configure_tdls_mode(), wlan_hdd_tdls_set_params() and wlan_hdd_update_tdls_info(). Change-Id: I03d4d74356ff6401772c69a7686352783cf22b6b CRs-Fixed: 1106726
Esse commit está contido em:
@@ -1791,16 +1791,11 @@ int wlan_hdd_tdls_set_params(struct net_device *dev,
|
||||
{
|
||||
hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
|
||||
hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
|
||||
tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
|
||||
tdlsCtx_t *pHddTdlsCtx;
|
||||
eTDLSSupportMode req_tdls_mode;
|
||||
tdlsInfo_t *tdlsParams;
|
||||
QDF_STATUS qdf_ret_status = QDF_STATUS_E_FAILURE;
|
||||
|
||||
if (NULL == pHddTdlsCtx) {
|
||||
hdd_err("TDLS not enabled!");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (wlan_hdd_tdls_check_config(config) != 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -1812,6 +1807,15 @@ int wlan_hdd_tdls_set_params(struct net_device *dev,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mutex_lock(&pHddCtx->tdls_lock);
|
||||
|
||||
pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
|
||||
if (NULL == pHddTdlsCtx) {
|
||||
mutex_unlock(&pHddCtx->tdls_lock);
|
||||
hdd_err("pHddTdlsCtx is NULL");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* copy the configuration only when given tdls mode is implicit trigger enable */
|
||||
if (eTDLS_SUPPORT_ENABLED == req_tdls_mode ||
|
||||
eTDLS_SUPPORT_EXTERNAL_CONTROL == req_tdls_mode) {
|
||||
@@ -1819,6 +1823,8 @@ int wlan_hdd_tdls_set_params(struct net_device *dev,
|
||||
sizeof(tdls_config_params_t));
|
||||
}
|
||||
|
||||
mutex_unlock(&pHddCtx->tdls_lock);
|
||||
|
||||
hdd_err("iw set tdls params: %d %d %d %d %d %d %d",
|
||||
config->tdls,
|
||||
config->tx_period_t,
|
||||
@@ -1921,16 +1927,10 @@ void wlan_hdd_update_tdls_info(hdd_adapter_t *adapter, bool tdls_prohibited,
|
||||
bool tdls_chan_swit_prohibited)
|
||||
{
|
||||
hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
|
||||
tdlsCtx_t *hdd_tdls_ctx = WLAN_HDD_GET_TDLS_CTX_PTR(adapter);
|
||||
tdlsCtx_t *hdd_tdls_ctx;
|
||||
tdlsInfo_t *tdls_param;
|
||||
QDF_STATUS qdf_ret_status = QDF_STATUS_E_FAILURE;
|
||||
|
||||
if (!hdd_tdls_ctx) {
|
||||
/* may be TDLS is not applicable for this adapter */
|
||||
hdd_err("HDD TDLS context is null");
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* If TDLS support is disabled then no need to update target */
|
||||
if (false == hdd_ctx->config->fEnableTDLSSupport) {
|
||||
hdd_err("TDLS not enabled");
|
||||
@@ -1942,6 +1942,14 @@ void wlan_hdd_update_tdls_info(hdd_adapter_t *adapter, bool tdls_prohibited,
|
||||
|
||||
mutex_lock(&hdd_ctx->tdls_lock);
|
||||
|
||||
hdd_tdls_ctx = WLAN_HDD_GET_TDLS_CTX_PTR(adapter);
|
||||
if (!hdd_tdls_ctx) {
|
||||
mutex_unlock(&hdd_ctx->tdls_lock);
|
||||
/* may be TDLS is not applicable for this adapter */
|
||||
hdd_err("HDD TDLS context is null");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (hdd_ctx->set_state_info.set_state_cnt == 0 &&
|
||||
tdls_prohibited) {
|
||||
mutex_unlock(&hdd_ctx->tdls_lock);
|
||||
@@ -1991,8 +1999,6 @@ void wlan_hdd_update_tdls_info(hdd_adapter_t *adapter, bool tdls_prohibited,
|
||||
tdls_param->vdev_id = adapter->sessionId;
|
||||
}
|
||||
|
||||
mutex_unlock(&hdd_ctx->tdls_lock);
|
||||
|
||||
tdls_param->tdls_state = hdd_ctx->tdls_mode;
|
||||
tdls_param->notification_interval_ms =
|
||||
hdd_tdls_ctx->threshold_config.tx_period_t;
|
||||
@@ -2006,6 +2012,8 @@ void wlan_hdd_update_tdls_info(hdd_adapter_t *adapter, bool tdls_prohibited,
|
||||
|
||||
tdls_param->tdls_options = 0;
|
||||
|
||||
mutex_unlock(&hdd_ctx->tdls_lock);
|
||||
|
||||
/* Do not enable TDLS offchannel, if AP prohibited TDLS channel switch */
|
||||
if ((hdd_ctx->config->fEnableTDLSOffChannel) &&
|
||||
(!tdls_chan_swit_prohibited)) {
|
||||
@@ -3435,10 +3443,6 @@ __wlan_hdd_cfg80211_configure_tdls_mode(struct wiphy *wiphy,
|
||||
if (NULL == adapter)
|
||||
return -EINVAL;
|
||||
|
||||
hdd_tdls_ctx = adapter->sessionCtx.station.pHddTdlsCtx;
|
||||
if (NULL == hdd_tdls_ctx)
|
||||
return -EINVAL;
|
||||
|
||||
if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_CONFIG_MAX,
|
||||
data, data_len,
|
||||
wlan_hdd_tdls_mode_configuration_policy)) {
|
||||
@@ -3472,6 +3476,12 @@ __wlan_hdd_cfg80211_configure_tdls_mode(struct wiphy *wiphy,
|
||||
|
||||
mutex_lock(&hdd_ctx->tdls_lock);
|
||||
|
||||
hdd_tdls_ctx = adapter->sessionCtx.station.pHddTdlsCtx;
|
||||
if (NULL == hdd_tdls_ctx) {
|
||||
mutex_unlock(&hdd_ctx->tdls_lock);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (tb[QCA_WLAN_VENDOR_ATTR_TDLS_CONFIG_TX_STATS_PERIOD]) {
|
||||
hdd_tdls_ctx->threshold_config.tx_period_t = nla_get_u32(
|
||||
tb[QCA_WLAN_VENDOR_ATTR_TDLS_CONFIG_TX_STATS_PERIOD]);
|
||||
|
Referência em uma nova issue
Block a user