From f214a5d1bedda48deba10e03cc1b502fffa1743f Mon Sep 17 00:00:00 2001 From: Amar Singhal Date: Tue, 3 Sep 2019 15:39:13 -0700 Subject: [PATCH] qcacld-3.0: Check frequency range correctly Check frequency range correctly. Include checks for 6 ghz frequenies also. Change-Id: I5bf10e150cb308fca0bf08af7518a96e1c13dc9d CRs-Fixed: 2521047 --- core/hdd/src/wlan_hdd_hostapd.c | 40 +++++++++++++-------------------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/core/hdd/src/wlan_hdd_hostapd.c b/core/hdd/src/wlan_hdd_hostapd.c index 65f306acba26..e9daf91aabec 100644 --- a/core/hdd/src/wlan_hdd_hostapd.c +++ b/core/hdd/src/wlan_hdd_hostapd.c @@ -3643,41 +3643,33 @@ int wlan_hdd_set_channel(struct wiphy *wiphy, mac_handle = hdd_ctx->mac_handle; - /* - * Do freq to chan conversion - * TODO: for 11a - */ + /* Check freq range */ + if ((wlan_reg_min_chan_freq() > + chandef->chan->center_freq) || + (wlan_reg_max_chan_freq() < chandef->chan->center_freq)) { + hdd_err("channel: %d is outside valid freq range", + chandef->chan->center_freq); + return -EINVAL; + } channel = ieee80211_frequency_to_channel(chandef->chan->center_freq); if (NL80211_CHAN_WIDTH_80P80 == chandef->width || NL80211_CHAN_WIDTH_160 == chandef->width) { + if ((wlan_reg_min_chan_freq() > chandef->center_freq2) || + (wlan_reg_max_chan_freq() < chandef->center_freq2)) { + hdd_err("center_freq2: %d is outside valid freq range", + chandef->center_freq2); + return -EINVAL; + } + if (chandef->center_freq2) channel_seg2 = ieee80211_frequency_to_channel( - chandef->center_freq2); + chandef->center_freq2); else hdd_err("Invalid center_freq2"); } - /* Check freq range */ - if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) || - (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel)) { - hdd_err("Channel: %d is outside valid range from %d to %d", - channel, WNI_CFG_CURRENT_CHANNEL_STAMIN, - WNI_CFG_CURRENT_CHANNEL_STAMAX); - return -EINVAL; - } - - /* Check freq range */ - - if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel_seg2) || - (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel_seg2)) { - hdd_err("Channel: %d is outside valid range from %d to %d", - channel_seg2, WNI_CFG_CURRENT_CHANNEL_STAMIN, - WNI_CFG_CURRENT_CHANNEL_STAMAX); - return -EINVAL; - } - num_ch = CFG_VALID_CHANNEL_LIST_LEN; if ((QDF_SAP_MODE != adapter->device_mode) &&