Pārlūkot izejas kodu

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
Ashish Kumar Dhanotiya 8 gadi atpakaļ
vecāks
revīzija
4da37920f4
2 mainītis faili ar 13 papildinājumiem un 3 dzēšanām
  1. 5 3
      core/hdd/src/wlan_hdd_main.c
  2. 8 0
      core/sme/src/common/sme_api.c

+ 5 - 3
core/hdd/src/wlan_hdd_main.c

@@ -5791,8 +5791,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;
 }
@@ -8392,8 +8396,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);

+ 8 - 0
core/sme/src/common/sme_api.c

@@ -988,6 +988,8 @@ 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;
+
 	tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
 
 	MTRACE(qdf_trace(QDF_MODULE_ID_SME,
@@ -997,6 +999,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) {
+		sms_log(pMac, LOGE, "invalid AP alpha2");
+		return  status;
+	}
+
 	status = csr_set_reg_info(hHal, apCntryCode);
 	if (!QDF_IS_STATUS_SUCCESS(status)) {
 		sms_log(pMac, LOGE, "csr_set_reg_info failed with status=%d",