فهرست منبع

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
sandhu 3 سال پیش
والد
کامیت
9598f6b6c4
2فایلهای تغییر یافته به همراه13 افزوده شده و 0 حذف شده
  1. 9 0
      dp/wifi3.0/dp_main.c
  2. 4 0
      dp/wifi3.0/dp_stats.c

+ 9 - 0
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];

+ 4 - 0
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 */