Browse Source

qcacld-3.0: Fix KW warning for pcl weight list

Add sanity check for index with NUM_CHANNELS and pcl_sz
when add 2.4G channel list.

Change-Id: I04ac1bcdb6720a4740be7c2f5e08f76b3c34d8c4
CRs-Fixed: 3025000
Liangwei Dong 3 years ago
parent
commit
2762576aec
1 changed files with 8 additions and 4 deletions
  1. 8 4
      components/cmn_services/policy_mgr/src/wlan_policy_mgr_core.c

+ 8 - 4
components/cmn_services/policy_mgr/src/wlan_policy_mgr_core.c

@@ -2310,11 +2310,15 @@ policy_mgr_add_24g_to_pcl(uint32_t *pcl_freqs, uint8_t *pcl_weights,
 {
 	uint32_t num_to_add, i;
 
+	if (*index >= NUM_CHANNELS || *index >= pcl_sz)
+		return;
 	num_to_add = QDF_MIN((*index + chlist_24g_len), pcl_sz) - *index;
-	qdf_mem_copy(&pcl_freqs[*index], chlist_24g,
-		     num_to_add * sizeof(*chlist_24g));
-	for (i = *index; i < *index + num_to_add; i++)
-		pcl_weights[i] = weight;
+	for (i = 0; i < num_to_add; i++) {
+		if ((i + *index) >= NUM_CHANNELS || (i + *index) >= pcl_sz)
+			break;
+		pcl_weights[i + *index] = weight;
+		pcl_freqs[i + *index] = chlist_24g[i];
+	}
 
 	*index = i;
 	policy_mgr_debug("Add 24g chlist len %d len %d index %d",