qcacld-3.0: Replace QDF_MAX_NUM_CHAN/POLICY_MGR_MAX_CHANNEL_LIST with NUM_CHANNELS

Currently QDF_MAX_NUM_CHAN/POLICY_MGR_MAX_CHANNEL_LIST aren't aligned with
NUM_CHANNELS, these unalignment may cause some potential OOB access.
So replace QDF_MAX_NUM_CHAN/POLICY_MGR_MAX_CHANNEL_LIST with NUM_CHANNELS
to keep unified.

Change-Id: Ib6c81a3979f2fd29ba1ec678f018a6704b599385
CRs-Fixed: 2644066
Este commit está contenido en:
Qun Zhang
2020-03-20 12:05:25 +08:00
cometido por nshrivas
padre 12d5bdc2e2
commit b4e2c33bab
Se han modificado 18 ficheros con 85 adiciones y 87 borrados

Ver fichero

@@ -28,8 +28,6 @@
/* Include files */
#include <wmi_unified_api.h>
#define POLICY_MGR_MAX_CHANNEL_LIST 128
/**
* Some max value greater than the max length of the channel list
*/
@@ -1145,8 +1143,8 @@ struct policy_mgr_hw_mode {
* @pcl_len: Number of channels in the PCL
*/
struct policy_mgr_pcl_list {
uint32_t pcl_list[POLICY_MGR_MAX_CHANNEL_LIST];
uint8_t weight_list[POLICY_MGR_MAX_CHANNEL_LIST];
uint32_t pcl_list[NUM_CHANNELS];
uint8_t weight_list[NUM_CHANNELS];
uint32_t pcl_len;
};
@@ -1163,12 +1161,12 @@ struct policy_mgr_pcl_list {
* @weight_list: Weights assigned by policy manager
*/
struct policy_mgr_pcl_chan_weights {
uint32_t pcl_list[POLICY_MGR_MAX_CHANNEL_LIST];
uint32_t pcl_list[NUM_CHANNELS];
uint32_t pcl_len;
uint32_t saved_chan_list[POLICY_MGR_MAX_CHANNEL_LIST];
uint32_t saved_chan_list[NUM_CHANNELS];
uint32_t saved_num_chan;
uint8_t weighed_valid_list[POLICY_MGR_MAX_CHANNEL_LIST];
uint8_t weight_list[POLICY_MGR_MAX_CHANNEL_LIST];
uint8_t weighed_valid_list[NUM_CHANNELS];
uint8_t weight_list[NUM_CHANNELS];
};
/**

Ver fichero

@@ -1375,8 +1375,8 @@ bool policy_mgr_is_sap_restart_required_after_sta_disconnect(
uint32_t op_ch_freq_list[MAX_NUMBER_OF_CONC_CONNECTIONS];
uint8_t vdev_id[MAX_NUMBER_OF_CONC_CONNECTIONS];
enum policy_mgr_con_mode mode;
uint32_t pcl_channels[QDF_MAX_NUM_CHAN + 1];
uint8_t pcl_weight[QDF_MAX_NUM_CHAN + 1];
uint32_t pcl_channels[NUM_CHANNELS + 1];
uint8_t pcl_weight[NUM_CHANNELS + 1];
struct policy_mgr_conc_connection_info info = {0};
uint8_t num_cxn_del = 0;
QDF_STATUS status;

Ver fichero

@@ -1671,7 +1671,7 @@ static QDF_STATUS policy_mgr_get_sbs_channels(
QDF_STATUS status = QDF_STATUS_SUCCESS;
uint32_t conn_index = 0, num_channels = 0;
uint32_t num_5g_channels = 0, cur_5g_ch_freq = 0;
uint32_t remaining_5g_ch_freqs[QDF_MAX_NUM_CHAN] = {};
uint32_t remaining_5g_ch_freqs[NUM_CHANNELS] = {};
uint32_t remaining_channel_index = 0;
uint32_t j = 0, i = 0, weight1, weight2;
@@ -1995,7 +1995,7 @@ void policy_mgr_set_weight_of_dfs_passive_channels_to_zero(
return;
if (len)
orig_channel_count = QDF_MIN(*len, QDF_MAX_NUM_CHAN);
orig_channel_count = QDF_MIN(*len, NUM_CHANNELS);
else {
policy_mgr_err("invalid number of channel length");
return;
@@ -3360,7 +3360,7 @@ uint32_t policy_mgr_get_sap_mandatory_chan_list_len(
void policy_mgr_init_sap_mandatory_2g_chan(struct wlan_objmgr_psoc *psoc)
{
uint32_t ch_freq_list[QDF_MAX_NUM_CHAN] = {0};
uint32_t ch_freq_list[NUM_CHANNELS] = {0};
uint32_t len = 0;
int i;
QDF_STATUS status;
@@ -3379,7 +3379,7 @@ void policy_mgr_init_sap_mandatory_2g_chan(struct wlan_objmgr_psoc *psoc)
}
pm_ctx->sap_mandatory_channels_len = 0;
for (i = 0; (i < len) && (i < QDF_MAX_NUM_CHAN); i++) {
for (i = 0; (i < len) && (i < NUM_CHANNELS); i++) {
if (WLAN_REG_IS_24GHZ_CH_FREQ(ch_freq_list[i])) {
policy_mgr_debug("Add chan %hu to mandatory list",
ch_freq_list[i]);
@@ -3393,7 +3393,7 @@ void policy_mgr_init_sap_mandatory_2g_chan(struct wlan_objmgr_psoc *psoc)
void policy_mgr_remove_sap_mandatory_chan(struct wlan_objmgr_psoc *psoc,
uint32_t ch_freq)
{
uint32_t ch_freq_list[QDF_MAX_NUM_CHAN] = {0};
uint32_t ch_freq_list[NUM_CHANNELS] = {0};
uint32_t num_chan = 0;
int i;
struct policy_mgr_psoc_priv_obj *pm_ctx;
@@ -3404,7 +3404,7 @@ void policy_mgr_remove_sap_mandatory_chan(struct wlan_objmgr_psoc *psoc,
return;
}
if (pm_ctx->sap_mandatory_channels_len >= QDF_MAX_NUM_CHAN) {
if (pm_ctx->sap_mandatory_channels_len >= NUM_CHANNELS) {
policy_mgr_err("Invalid channel len %d ",
pm_ctx->sap_mandatory_channels_len);
return;

Ver fichero

@@ -218,8 +218,8 @@ void policy_mgr_update_with_safe_channel_list(struct wlan_objmgr_psoc *psoc,
uint8_t *weight_list,
uint32_t weight_len)
{
uint32_t current_channel_list[QDF_MAX_NUM_CHAN];
uint8_t org_weight_list[QDF_MAX_NUM_CHAN];
uint32_t current_channel_list[NUM_CHANNELS];
uint8_t org_weight_list[NUM_CHANNELS];
uint8_t is_unsafe = 1;
uint8_t i, j;
uint32_t safe_channel_count = 0, current_channel_count = 0;
@@ -233,7 +233,7 @@ void policy_mgr_update_with_safe_channel_list(struct wlan_objmgr_psoc *psoc,
}
if (len) {
current_channel_count = QDF_MIN(*len, QDF_MAX_NUM_CHAN);
current_channel_count = QDF_MIN(*len, NUM_CHANNELS);
} else {
policy_mgr_err("invalid number of channel length");
return;
@@ -249,7 +249,7 @@ void policy_mgr_update_with_safe_channel_list(struct wlan_objmgr_psoc *psoc,
qdf_mem_zero(pcl_channels,
current_channel_count * sizeof(*pcl_channels));
qdf_mem_copy(org_weight_list, weight_list, QDF_MAX_NUM_CHAN);
qdf_mem_copy(org_weight_list, weight_list, NUM_CHANNELS);
qdf_mem_zero(weight_list, weight_len);
policy_mgr_get_sta_sap_scc_lte_coex_chnl(psoc, &scc_on_lte_coex);
@@ -313,12 +313,12 @@ static QDF_STATUS policy_mgr_modify_pcl_based_on_dnbs(
uint32_t *pcl_len_org)
{
uint32_t i, pcl_len = 0;
uint32_t pcl_list[QDF_MAX_NUM_CHAN];
uint8_t weight_list[QDF_MAX_NUM_CHAN];
uint32_t pcl_list[NUM_CHANNELS];
uint8_t weight_list[NUM_CHANNELS];
bool ok;
QDF_STATUS status = QDF_STATUS_E_FAILURE;
if (*pcl_len_org > QDF_MAX_NUM_CHAN) {
if (*pcl_len_org > NUM_CHANNELS) {
policy_mgr_err("Invalid PCL List Length %d", *pcl_len_org);
return status;
}
@@ -444,7 +444,7 @@ static QDF_STATUS policy_mgr_modify_sap_pcl_based_on_dfs(
policy_mgr_err("Invalid Context");
return QDF_STATUS_E_FAILURE;
}
if (*pcl_len_org > QDF_MAX_NUM_CHAN) {
if (*pcl_len_org > NUM_CHANNELS) {
policy_mgr_err("Invalid PCL List Length %d", *pcl_len_org);
return QDF_STATUS_E_FAILURE;
}
@@ -479,8 +479,8 @@ static QDF_STATUS policy_mgr_modify_sap_pcl_based_on_nol(
uint32_t *pcl_len_org)
{
uint32_t i, pcl_len = 0;
uint32_t pcl_list[QDF_MAX_NUM_CHAN];
uint8_t weight_list[QDF_MAX_NUM_CHAN];
uint32_t pcl_list[NUM_CHANNELS];
uint8_t weight_list[NUM_CHANNELS];
struct policy_mgr_psoc_priv_obj *pm_ctx;
pm_ctx = policy_mgr_get_context(psoc);
@@ -488,7 +488,7 @@ static QDF_STATUS policy_mgr_modify_sap_pcl_based_on_nol(
policy_mgr_err("Invalid Context");
return QDF_STATUS_E_FAILURE;
}
if (*pcl_len_org > QDF_MAX_NUM_CHAN) {
if (*pcl_len_org > NUM_CHANNELS) {
policy_mgr_err("Invalid PCL List Length %d", *pcl_len_org);
return QDF_STATUS_E_FAILURE;
}
@@ -517,8 +517,8 @@ policy_mgr_modify_pcl_based_on_srd(struct wlan_objmgr_psoc *psoc,
uint32_t *pcl_len_org)
{
uint32_t i, pcl_len = 0;
uint32_t pcl_list[QDF_MAX_NUM_CHAN];
uint8_t weight_list[QDF_MAX_NUM_CHAN];
uint32_t pcl_list[NUM_CHANNELS];
uint8_t weight_list[NUM_CHANNELS];
struct policy_mgr_psoc_priv_obj *pm_ctx;
bool is_etsi13_srd_chan_allowed_in_mas_mode = true;
@@ -533,7 +533,7 @@ policy_mgr_modify_pcl_based_on_srd(struct wlan_objmgr_psoc *psoc,
if (is_etsi13_srd_chan_allowed_in_mas_mode)
return QDF_STATUS_SUCCESS;
if (*pcl_len_org > QDF_MAX_NUM_CHAN) {
if (*pcl_len_org > NUM_CHANNELS) {
policy_mgr_err("Invalid PCL List Length %d", *pcl_len_org);
return QDF_STATUS_E_FAILURE;
}
@@ -1960,8 +1960,8 @@ policy_mgr_get_nondfs_preferred_channel(struct wlan_objmgr_psoc *psoc,
enum policy_mgr_con_mode mode,
bool for_existing_conn)
{
uint32_t pcl_channels[QDF_MAX_NUM_CHAN];
uint8_t pcl_weight[QDF_MAX_NUM_CHAN];
uint32_t pcl_channels[NUM_CHANNELS];
uint8_t pcl_weight[NUM_CHANNELS];
struct policy_mgr_psoc_priv_obj *pm_ctx;
/*
@@ -2036,7 +2036,7 @@ QDF_STATUS policy_mgr_get_valid_chans_from_range(
struct wlan_objmgr_psoc *psoc, uint32_t *ch_freq_list,
uint32_t *ch_cnt, enum policy_mgr_con_mode mode)
{
uint8_t ch_weight_list[QDF_MAX_NUM_CHAN] = {0};
uint8_t ch_weight_list[NUM_CHANNELS] = {0};
uint32_t ch_weight_len;
QDF_STATUS status = QDF_STATUS_E_FAILURE;
size_t chan_index = 0;
@@ -2198,8 +2198,8 @@ QDF_STATUS policy_mgr_modify_sap_pcl_based_on_mandatory_channel(
for (i = 0; i < *pcl_len_org; i++) {
found = false;
if (i >= QDF_MAX_NUM_CHAN) {
policy_mgr_debug("index is exceeding QDF_MAX_NUM_CHAN");
if (i >= NUM_CHANNELS) {
policy_mgr_debug("index is exceeding NUM_CHANNELS");
break;
}
for (j = 0; j < pm_ctx->sap_mandatory_channels_len; j++) {
@@ -2209,7 +2209,7 @@ QDF_STATUS policy_mgr_modify_sap_pcl_based_on_mandatory_channel(
break;
}
}
if (found && (pcl_len < QDF_MAX_NUM_CHAN)) {
if (found && (pcl_len < NUM_CHANNELS)) {
pcl_list_org[pcl_len] = pcl_list_org[i];
weight_list_org[pcl_len++] = weight_list_org[i];
}
@@ -2290,7 +2290,7 @@ QDF_STATUS policy_mgr_get_valid_chan_weights(struct wlan_objmgr_psoc *psoc,
return QDF_STATUS_E_FAILURE;
}
qdf_mem_set(weight->weighed_valid_list, QDF_MAX_NUM_CHAN,
qdf_mem_set(weight->weighed_valid_list, NUM_CHANNELS,
WEIGHT_OF_DISALLOWED_CHANNELS);
qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock);
if (policy_mgr_mode_specific_connection_count(
@@ -2365,8 +2365,8 @@ uint32_t policy_mgr_get_alternate_channel_for_sap(
struct wlan_objmgr_psoc *psoc, uint8_t sap_vdev_id,
uint32_t sap_ch_freq)
{
uint32_t pcl_channels[QDF_MAX_NUM_CHAN];
uint8_t pcl_weight[QDF_MAX_NUM_CHAN];
uint32_t pcl_channels[NUM_CHANNELS];
uint8_t pcl_weight[NUM_CHANNELS];
uint32_t ch_freq = 0;
uint32_t pcl_len = 0;
struct policy_mgr_conc_connection_info info;