Преглед изворни кода

qcacld-3.0: Fix potential static code analysis issues

Fix potential null pointer access during sap open
session and validation of the session id which could
be reported during static code analysis.

Change-Id: I6146c7223c586df06c08c76abd9e38a3c1ad1c4b
CRs-Fixed: 979960
Chandrasekaran, Manishekar пре 9 година
родитељ
комит
d3cb4778fe
2 измењених фајлова са 9 додато и 1 уклоњено
  1. 6 0
      core/sap/src/sap_module.c
  2. 3 1
      core/sme/src/common/sme_api.c

+ 6 - 0
core/sap/src/sap_module.c

@@ -201,6 +201,12 @@ QDF_STATUS wlansap_start(void *pCtx, enum tQDF_ADAPTER_MODE mode,
 	}
 
 	hal = (tHalHandle) CDS_GET_HAL_CB(pSapCtx->p_cds_gctx);
+	if (!hal) {
+		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
+			"%s: Invalid HAL pointer", __func__);
+		return QDF_STATUS_E_INVAL;
+	}
+
 	qdf_ret_status = sap_open_session(hal, pSapCtx, session_id);
 
 	if (QDF_STATUS_SUCCESS != qdf_ret_status) {

+ 3 - 1
core/sme/src/common/sme_api.c

@@ -15130,7 +15130,9 @@ bool sme_is_session_id_valid(tHalHandle hal, uint32_t session_id)
 {
 	tpAniSirGlobal mac = PMAC_STRUCT(hal);
 	if (!mac) {
-		sms_log(mac, LOGE, FL("null mac pointer"));
+		/* Using QDF_TRACE since mac is not available for sms_log */
+		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
+			"%s: null mac pointer", __func__);
 		return false;
 	}