From b3b2194db6042b5db0193a137ce48c2c4be6563c Mon Sep 17 00:00:00 2001 From: gaurank kathpalia Date: Fri, 10 Jan 2020 15:09:33 +0530 Subject: [PATCH] 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 --- core/hdd/src/wlan_hdd_cfg80211.c | 25 ++++++++----------------- core/hdd/src/wlan_hdd_main.c | 15 +++++++-------- 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index f4834d1f763f..49d5d2510c6c 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -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", diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index d1d9892439e5..bc1f1f529fb9 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -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",