From 7c367ef8f10f1192dc2a583e583364f09e253123 Mon Sep 17 00:00:00 2001 From: Amar Singhal Date: Mon, 3 Apr 2017 12:05:58 -0700 Subject: qcacld-3.0: Check for validity of country code Check for validity of country code coming from hostapd configuration. If hostapd country code is not valid; SAP may stop since invalid country code lead to setting of world reg-domain.Also program the default country code after wiphy is initialized, rather than when an interface is turned on. Change-Id: Iefc250df741a95cc4b21bdd4fe7e4c076fdf3b06 CRs-Fixed: 2029127 --- core/hdd/src/wlan_hdd_main.c | 8 +++++--- core/sme/src/common/sme_api.c | 7 +++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 97e01bf424d0..f473c90679e7 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -5563,8 +5563,12 @@ static int hdd_wiphy_init(hdd_context_t *hdd_ctx) /* registration of wiphy dev with cfg80211 */ ret_val = wlan_hdd_cfg80211_register(wiphy); - if (0 > ret_val) + if (0 > ret_val) { hdd_err("wiphy registration failed"); + return ret_val; + } + + hdd_program_country_code(hdd_ctx); return ret_val; } @@ -8019,8 +8023,6 @@ static int hdd_pre_enable_configure(hdd_context_t *hdd_ctx) if (ret) goto out; - hdd_program_country_code(hdd_ctx); - ret = wma_cli_set_command(0, WMI_PDEV_PARAM_ARP_AC_OVERRIDE, hdd_ctx->config->arp_ac_category, PDEV_CMD); diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c index 2c0dd6f748db..1c6ded649923 100644 --- a/core/sme/src/common/sme_api.c +++ b/core/sme/src/common/sme_api.c @@ -1330,6 +1330,7 @@ QDF_STATUS sme_get_soft_ap_domain(tHalHandle hHal, v_REGDOMAIN_t *domainIdSoftAp QDF_STATUS sme_set_reg_info(tHalHandle hHal, uint8_t *apCntryCode) { QDF_STATUS status = QDF_STATUS_E_FAILURE; + int32_t ctry_val; MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_MSG_SET_REGINFO, NO_SESSION, 0)); @@ -1338,6 +1339,12 @@ QDF_STATUS sme_set_reg_info(tHalHandle hHal, uint8_t *apCntryCode) return status; } + ctry_val = cds_get_country_from_alpha2(apCntryCode); + if (ctry_val == CTRY_DEFAULT) { + sme_err("invalid AP alpha2"); + return status; + } + status = csr_set_reg_info(hHal, apCntryCode); if (!QDF_IS_STATUS_SUCCESS(status)) { sme_err("csr_set_reg_info failed with status: %d", status); -- cgit v1.2.3