From aadbf5a316e4f3e67ab82fb5eebcfc10f752da8f Mon Sep 17 00:00:00 2001 From: Aditya Kodukula Date: Tue, 11 May 2021 14:28:34 -0700 Subject: [PATCH] qcacld-3.0: Add check to validate the Tx chainmask value Add a sanity check to validate the Tx chainmask value sent from the user space for each HW mode. Change-Id: I2705efe20fcb13bf8343088ceecb4207e2562789 CRs-Fixed: 2943363 --- core/wma/src/wma_main.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/core/wma/src/wma_main.c b/core/wma/src/wma_main.c index 69ed2e5fb3fa..836e186ee6ee 100644 --- a/core/wma/src/wma_main.c +++ b/core/wma/src/wma_main.c @@ -846,6 +846,28 @@ static void wma_set_dtim_period(tp_wma_handle wma, } +static inline bool wma_is_tx_chainmask_valid(int value, + struct target_psoc_info *tgt_hdl) +{ + struct wlan_psoc_host_mac_phy_caps *mac_phy_cap; + uint8_t total_mac_phy_cnt, i; + + mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl); + if (!mac_phy_cap) { + wma_err("Invalid MAC PHY capabilities handle"); + return false; + } + + total_mac_phy_cnt = target_psoc_get_total_mac_phy_cnt(tgt_hdl); + for (i = 0; i < total_mac_phy_cnt; i++) { + if (((mac_phy_cap[i].tx_chain_mask_5G) & (value))) { + return true; + } + } + + return false; +} + /** * wma_process_cli_set_cmd() - set parameters to fw * @wma: wma handle @@ -917,6 +939,14 @@ static void wma_process_cli_set_cmd(tp_wma_handle wma, return; } } + + if (privcmd->param_id == WMI_PDEV_PARAM_TX_CHAIN_MASK) { + if (!wma_is_tx_chainmask_valid(privcmd->param_value, + tgt_hdl)) { + wma_debug("Chainmask value is invalid"); + return; + } + } pdev_param.param_id = privcmd->param_id; pdev_param.param_value = privcmd->param_value; ret = wmi_unified_pdev_param_send(wma->wmi_handle,