From e23b6bc5fcf51d176d1dd868630ac244dcc19491 Mon Sep 17 00:00:00 2001 From: Varun Reddy Yeturu Date: Mon, 8 Jan 2018 13:18:41 -0800 Subject: [PATCH] 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 --- src/wlan_policy_mgr_action.c | 4 ++-- src/wlan_policy_mgr_get_set_utils.c | 6 ++++-- src/wlan_policy_mgr_pcl.c | 11 ++++++++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/wlan_policy_mgr_action.c b/src/wlan_policy_mgr_action.c index 7e57b359ef08..5e8031115551 100644 --- a/src/wlan_policy_mgr_action.c +++ b/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"); diff --git a/src/wlan_policy_mgr_get_set_utils.c b/src/wlan_policy_mgr_get_set_utils.c index e5ac3c384e39..d477600da5df 100644 --- a/src/wlan_policy_mgr_get_set_utils.c +++ b/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]; diff --git a/src/wlan_policy_mgr_pcl.c b/src/wlan_policy_mgr_pcl.c index a8118a10a151..ce627c690a70 100644 --- a/src/wlan_policy_mgr_pcl.c +++ b/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,