Parcourir la source

qcacld-3.0: Check session Id against max adapters

The current HDD session Id sanity check only checks for the magic
"invalid session Id" value. However, anything greater than or equal to
MAX_NUMBER_OF_ADAPTERS is an invalid session Id. Update the sanity check
to reject any session Id greater than or equal to
MAX_NUMBER_OF_ADAPTERS.

Change-Id: I7c5a3b82afde073e92fcd0dbf55002fa11a980b2
CRs-Fixed: 2283584
Dustin Brown il y a 6 ans
Parent
commit
bee8283248
3 fichiers modifiés avec 13 ajouts et 8 suppressions
  1. 1 3
      core/hdd/inc/wlan_hdd_main.h
  2. 11 4
      core/hdd/src/wlan_hdd_main.c
  3. 1 1
      core/hdd/src/wlan_hdd_power.c

+ 1 - 3
core/hdd/inc/wlan_hdd_main.h

@@ -243,8 +243,6 @@ static inline bool in_compat_syscall(void) { return is_compat_task(); }
 /* rcpi request timeout in milli seconds */
 #define WLAN_WAIT_TIME_RCPI 500
 
-#define MAX_NUMBER_OF_ADAPTERS 4
-
 #define MAX_CFG_STRING_LEN  255
 
 /* Maximum time(ms) to wait for external acs response */
@@ -2790,7 +2788,7 @@ hdd_wlan_nla_put_u64(struct sk_buff *skb, int attrtype, u64 value)
 
 static inline int wlan_hdd_validate_session_id(u8 session_id)
 {
-	if (session_id != HDD_SESSION_ID_INVALID)
+	if (session_id < CSR_ROAM_SESSION_MAX)
 		return 0;
 
 	return -EINVAL;

+ 11 - 4
core/hdd/src/wlan_hdd_main.c

@@ -943,7 +943,7 @@ int hdd_validate_adapter(struct hdd_adapter *adapter)
 		return -EAGAIN;
 	}
 
-	if (adapter->session_id >= MAX_NUMBER_OF_ADAPTERS) {
+	if (adapter->session_id >= CSR_ROAM_SESSION_MAX) {
 		hdd_err("bad adapter session Id: %u", adapter->session_id);
 		return -EINVAL;
 	}
@@ -2035,7 +2035,14 @@ void hdd_update_tgt_cfg(hdd_handle_t hdd_handle, struct wma_tgt_cfg *cfg)
 	qdf_mem_copy(&hdd_ctx->hw_bd_info, &cfg->hw_bd_info,
 		     sizeof(cfg->hw_bd_info));
 
-	hdd_ctx->max_intf_count = cfg->max_intf_count;
+	if (cfg->max_intf_count > CSR_ROAM_SESSION_MAX) {
+		hdd_err("fw max vdevs (%u) > host max vdevs (%u); using %u",
+			cfg->max_intf_count, CSR_ROAM_SESSION_MAX,
+			CSR_ROAM_SESSION_MAX);
+		hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX;
+	} else {
+		hdd_ctx->max_intf_count = cfg->max_intf_count;
+	}
 
 	hdd_lpass_target_config(hdd_ctx, cfg);
 
@@ -7868,7 +7875,7 @@ hdd_display_netif_queue_history_compact(struct hdd_context *hdd_ctx)
 	uint32_t comb_log_str_size;
 	struct hdd_adapter *adapter = NULL;
 
-	comb_log_str_size = (ADAP_NETIFQ_LOG_LEN * MAX_NUMBER_OF_ADAPTERS) + 1;
+	comb_log_str_size = (ADAP_NETIFQ_LOG_LEN * CSR_ROAM_SESSION_MAX) + 1;
 	comb_log_str = qdf_mem_malloc(comb_log_str_size);
 	if (!comb_log_str) {
 		hdd_err("failed to alloc comb_log_str");
@@ -8793,7 +8800,7 @@ static int hdd_context_init(struct hdd_context *hdd_ctx)
 	qdf_spinlock_create(&hdd_ctx->sta_update_info_lock);
 	qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock);
 
-	qdf_list_create(&hdd_ctx->hdd_adapters, MAX_NUMBER_OF_ADAPTERS);
+	qdf_list_create(&hdd_ctx->hdd_adapters, 0);
 
 	ret = hdd_scan_context_init(hdd_ctx);
 	if (ret)

+ 1 - 1
core/hdd/src/wlan_hdd_power.c

@@ -1687,7 +1687,7 @@ static int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
 
 	/* flush any pending powersave timers */
 	hdd_for_each_adapter(hdd_ctx, adapter) {
-		if (adapter->session_id >= MAX_NUMBER_OF_ADAPTERS)
+		if (wlan_hdd_validate_session_id(adapter->session_id))
 			continue;
 
 		sme_ps_timer_flush_sync(mac_handle, adapter->session_id);