From 9598f6b6c40234fddc13d83594df9a217993d72b Mon Sep 17 00:00:00 2001 From: sandhu Date: Thu, 10 Feb 2022 10:57:09 -0800 Subject: [PATCH] qcacmn: Resolve static analysis issue check null pointer for soc return val and check array index input for out of bound access. Change-Id: Ib1d52f70128eaf9ba24e9024440490e470fec3d4 CRs-Fixed: 3127451 --- dp/wifi3.0/dp_main.c | 9 +++++++++ dp/wifi3.0/dp_stats.c | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/dp/wifi3.0/dp_main.c b/dp/wifi3.0/dp_main.c index ecf2472b60..1045779f21 100644 --- a/dp/wifi3.0/dp_main.c +++ b/dp/wifi3.0/dp_main.c @@ -10835,6 +10835,7 @@ QDF_STATUS dp_sysfs_fill_stats(ol_txrx_soc_handle soc_hdl, uint32_t host_stats = 0; enum cdp_stats stats; struct cdp_txrx_stats_req req; + uint32_t num_stats; struct dp_soc *soc = NULL; if (!soc_hdl) { @@ -10863,6 +10864,14 @@ QDF_STATUS dp_sysfs_fill_stats(ol_txrx_soc_handle soc_hdl, if (stats > CDP_TXRX_MAX_STATS) stats = stats + DP_CURR_FW_STATS_AVAIL - DP_HTT_DBG_EXT_STATS_MAX; + num_stats = QDF_ARRAY_SIZE(dp_stats_mapping_table); + + if (stats >= num_stats) { + dp_cdp_err("%pK : Invalid stats option: %d, max num stats: %d", + soc, stats, num_stats); + return QDF_STATUS_E_INVAL; + } + /* build request */ fw_stats = dp_stats_mapping_table[stats][STATS_FW]; host_stats = dp_stats_mapping_table[stats][STATS_HOST]; diff --git a/dp/wifi3.0/dp_stats.c b/dp/wifi3.0/dp_stats.c index 11a021fa58..b973e3f268 100644 --- a/dp/wifi3.0/dp_stats.c +++ b/dp/wifi3.0/dp_stats.c @@ -315,7 +315,11 @@ void DP_PRINT_STATS(const char *fmt, ...) struct dp_soc *soc = NULL; soc_void = cds_get_context(QDF_MODULE_ID_SOC); + if (!soc_void) + return; + soc = cdp_soc_t_to_dp_soc(soc_void); + va_start(val, fmt); QDF_VTRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH, (char *)fmt, val); /* writing to the buffer */