Browse Source

qcacld-3.0: Add NULL checks before dereferencing

Add NULL checks before dereferencing in:
1) BMI layer
2) HTT layer
3) EPPING layer.

Change-Id: I9998d4aeb983dc101121a71d791d7ec626e3f5d4
CRs-Fixed: 1036390
Himanshu Agarwal 8 years ago
parent
commit
879a3bec5c
3 changed files with 21 additions and 3 deletions
  1. 3 3
      core/bmi/src/bmi.c
  2. 12 0
      core/dp/htt/htt_tx.c
  3. 6 0
      core/utils/epping/src/epping_main.c

+ 3 - 3
core/bmi/src/bmi.c

@@ -218,15 +218,15 @@ QDF_STATUS bmi_download_firmware(struct ol_context *ol_ctx)
 {
 	struct hif_opaque_softc *scn = ol_ctx->scn;
 
-	if (NO_BMI || !hif_needs_bmi(scn))
-		return QDF_STATUS_SUCCESS;
-
 	if (!scn) {
 		BMI_ERR("Invalid scn context");
 		bmi_assert(0);
 		return QDF_STATUS_NOT_INITIALIZED;
 	}
 
+	if (NO_BMI || !hif_needs_bmi(scn))
+		return QDF_STATUS_SUCCESS;
+
 	return bmi_firmware_download(ol_ctx);
 }
 

+ 12 - 0
core/dp/htt/htt_tx.c

@@ -1479,6 +1479,12 @@ void htt_fill_wisa_ext_header(qdf_nbuf_t msdu,
 	void *qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
 	QDF_STATUS status;
 
+	if (!qdf_ctx) {
+		QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
+			"%s: qdf_ctx is NULL", __func__);
+		return;
+	}
+
 	local_desc_ext->valid_mcs_mask = 1;
 	if (WISA_MODE_EXT_HEADER_6MBPS == type)
 		local_desc_ext->mcs_mask = htt_ofdm_datarate_6_mbps;
@@ -1593,6 +1599,12 @@ htt_tx_desc_init(htt_pdev_handle pdev,
 	void *qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
 	QDF_STATUS status;
 
+	if (!qdf_ctx) {
+		QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
+			"%s: qdf_ctx is NULL", __func__);
+		return;
+	}
+
 	word0 = (uint32_t *) htt_tx_desc;
 	word1 = word0 + 1;
 	/*

+ 6 - 0
core/utils/epping/src/epping_main.c

@@ -262,6 +262,12 @@ int epping_enable(struct device *parent_dev)
 	pEpping_ctx->target_type = tgt_info->target_type;
 
 	ol_ctx = cds_get_context(QDF_MODULE_ID_BMI);
+	if (!ol_ctx) {
+		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_FATAL,
+			  "%s: ol_ctx is NULL", __func__);
+		return A_ERROR;
+	}
+
 	epping_update_ol_config();
 #ifndef FEATURE_BMI_2
 	/* Initialize BMI and Download firmware */