qcacld-3.0: Check for valid BW in monitor mode

Check for invalid BW if received as part of
monitor mode vdev start command and reject if
invalid.

Change-Id: I1dfd7936af354622c52295cfba16941b96dfe649
CRs-Fixed: 2600906
This commit is contained in:
gaurank kathpalia 2020-01-10 15:09:33 +05:30 • committed by nshrivas
commit b3b2194db6
2 changed files with 15 additions and 25 deletions

View file

@ -22529,8 +22529,6 @@ static int __wlan_hdd_cfg80211_set_mon_ch(struct wiphy *wiphy,
mac_handle_t mac_handle;
struct qdf_mac_addr bssid;
struct csr_roam_profile roam_profile;
struct ch_params ch_params;
uint8_t sec_ch = 0;
int ret;
uint16_t chan_num = cds_freq_to_chan(chandef->chan->center_freq);
enum channel_state chan_freq_state;
@ -22565,6 +22563,12 @@ static int __wlan_hdd_cfg80211_set_mon_ch(struct wiphy *wiphy,
/* Verify the BW before accepting this request */
ch_width = hdd_map_nl_chan_width(chandef->width);
if (ch_width > CH_WIDTH_10MHZ ||
(!cds_is_sub_20_mhz_enabled() && ch_width > CH_WIDTH_160MHZ)) {
hdd_err("invalid BW received %d", ch_width);
return -EINVAL;
}
max_fw_bw = sme_get_vht_ch_width();
if ((ch_width == CH_WIDTH_160MHZ &&
@ -22587,26 +22591,13 @@ static int __wlan_hdd_cfg80211_set_mon_ch(struct wiphy *wiphy,
qdf_mem_copy(bssid.bytes, adapter->mac_addr.bytes,
QDF_MAC_ADDR_SIZE);
ch_params.ch_width = ch_width;
/*
* CDS api expects secondary channel for calculating
* the channel params
*/
if ((ch_params.ch_width == CH_WIDTH_40MHZ) &&
(WLAN_REG_IS_24GHZ_CH(chan_num))) {
if (chan_num >= 1 && chan_num <= 5)
sec_ch = chan_num + 4;
else if (chan_num >= 6 && chan_num <= 13)
sec_ch = chan_num - 4;
}
wlan_reg_set_channel_params(hdd_ctx->pdev, chan_num,
sec_ch, &ch_params);
if (wlan_hdd_change_hw_mode_for_given_chnl(adapter, chan_num,
POLICY_MGR_UPDATE_REASON_SET_OPER_CHAN)) {
hdd_err("Failed to change hw mode");
return -EINVAL;
}
status = sme_roam_channel_change_req(mac_handle, bssid, &ch_params,
status = sme_roam_channel_change_req(mac_handle, bssid,
&roam_profile.ch_params,
&roam_profile);
if (status) {
hdd_err("Failed to set sme_RoamChannel for monitor mode status: %d",

View file

@ -6930,7 +6930,6 @@ int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, uint32_t chan,
QDF_STATUS status;
struct qdf_mac_addr bssid;
struct csr_roam_profile roam_profile;
struct ch_params ch_params;
enum phy_ch_width max_fw_bw;
enum phy_ch_width ch_width;
@ -6948,6 +6947,12 @@ int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, uint32_t chan,
/* Verify the BW before accepting this request */
ch_width = bandwidth;
if (ch_width > CH_WIDTH_10MHZ ||
(!cds_is_sub_20_mhz_enabled() && ch_width > CH_WIDTH_160MHZ)) {
hdd_err("invalid BW received %d", ch_width);
return -EINVAL;
}
max_fw_bw = sme_get_vht_ch_width();
hdd_debug("max fw BW %d ch width %d", max_fw_bw, ch_width);
@ -6992,12 +6997,6 @@ int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, uint32_t chan,
qdf_mem_copy(bssid.bytes, adapter->mac_addr.bytes,
QDF_MAC_ADDR_SIZE);
ch_params.ch_width = bandwidth;
wlan_reg_set_channel_params(hdd_ctx->pdev, chan, 0, &ch_params);
if (ch_params.ch_width == CH_WIDTH_INVALID) {
hdd_err("Invalid capture channel or bandwidth for a country");
return -EINVAL;
}
if (wlan_hdd_change_hw_mode_for_given_chnl(adapter, chan,
POLICY_MGR_UPDATE_REASON_SET_OPER_CHAN)) {
hdd_err("Failed to change hw mode");
@ -7005,7 +7004,7 @@ int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, uint32_t chan,
}
status = sme_roam_channel_change_req(hdd_ctx->mac_handle,
bssid, &ch_params,
bssid, &roam_profile.ch_params,
&roam_profile);
if (status) {
hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode",