Prechádzať zdrojové kódy

qcacmn: Fix static analysis issues in policy manager

1) Check for policy manager context to be non NULL before
   dereferncing and return if it is NULL.
2) Use QDF_MAX_NUM_CHAN consistently to represent the maximum
   number of channels supported.

Change-Id: I3393bc801dd780d881423c8be346e74ac6d3ac6c
CRs-Fixed: 2160770
Varun Reddy Yeturu 7 rokov pred
rodič
commit
706ab89167

+ 2 - 2
umac/cmn_services/policy_mgr/src/wlan_policy_mgr_action.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -432,7 +432,7 @@ QDF_STATUS policy_mgr_next_actions(struct wlan_objmgr_psoc *psoc,
 {
 	QDF_STATUS status = QDF_STATUS_E_FAILURE;
 	struct policy_mgr_hw_mode_params hw_mode;
-	struct dbs_nss nss_dbs;
+	struct dbs_nss nss_dbs = {0};
 
 	if (policy_mgr_is_hw_dbs_capable(psoc) == false) {
 		policy_mgr_err("driver isn't dbs capable, no further action needed");

+ 4 - 2
umac/cmn_services/policy_mgr/src/wlan_policy_mgr_get_set_utils.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -2580,8 +2580,10 @@ uint32_t policy_mgr_get_hw_dbs_nss(struct wlan_objmgr_psoc *psoc,
 	struct policy_mgr_psoc_priv_obj *pm_ctx;
 
 	pm_ctx = policy_mgr_get_context(psoc);
-	if (!pm_ctx)
+	if (!pm_ctx) {
 		policy_mgr_err("Invalid Context");
+		return final_max_rf_chains;
+	}
 
 	for (i = 0; i < pm_ctx->num_dbs_hw_modes; i++) {
 		param = pm_ctx->hw_mode.hw_mode_list[i];

+ 8 - 3
umac/cmn_services/policy_mgr/src/wlan_policy_mgr_pcl.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -171,9 +171,14 @@ void policy_mgr_reg_chan_change_callback(struct wlan_objmgr_psoc *psoc,
 		return;
 	}
 
+	/*
+	 * The ch_list buffer can accomadate a maximum of
+	 * NUM_CHANNELS and hence the ch_cnt should also not
+	 * exceed NUM_CHANNELS.
+	 */
 	pm_ctx->unsafe_channel_count = avoid_freq_ind->chan_list.ch_cnt >=
-			QDF_MAX_NUM_CHAN ?
-			QDF_MAX_NUM_CHAN : avoid_freq_ind->chan_list.ch_cnt;
+			NUM_CHANNELS ?
+			NUM_CHANNELS : avoid_freq_ind->chan_list.ch_cnt;
 	if (pm_ctx->unsafe_channel_count)
 		qdf_mem_copy(pm_ctx->unsafe_channel_list,
 			avoid_freq_ind->chan_list.ch_list,