Quellcode durchsuchen

qcacld-3.0: Add NULL check for qdf_ctx

Add NULL check for pointer qdf_ctx as it returned from call to
function 'cds_get_context' may be NULL and could be dereferenced.

Change-Id: Iea44cd1a2d20ee04d1720c4e8af1065320a589fd
CRs-Fixed: 1024778
Yuanyuan Liu vor 8 Jahren
Ursprung
Commit
9736118d7e

+ 5 - 0
core/cds/src/cds_concurrency.c

@@ -4458,6 +4458,11 @@ void cds_update_with_safe_channel_list(uint8_t *pcl_channels, uint32_t *len,
 	uint32_t safe_channel_count = 0, current_channel_count = 0;
 	qdf_device_t qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
 
+	if (!qdf_ctx) {
+		cds_err("qdf_ctx is NULL");
+		return;
+	}
+
 	if (len) {
 		current_channel_count = QDF_MIN(*len, MAX_NUM_CHAN);
 	} else {

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

@@ -372,6 +372,12 @@ void sap_update_unsafe_channel_list(ptSapContext pSapCtx)
 	uint16_t unsafe_channel_count = 0;
 	qdf_device_t qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
 
+	if (!qdf_ctx) {
+		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_FATAL,
+			  "qdf_ctx is NULL");
+		return;
+	}
+
 	/* Flush, default set all channel safe */
 	for (i = 0; i < NUM_CHANNELS; i++) {
 		safe_channels[i].isSafe = true;

+ 13 - 1
core/utils/epping/src/epping_txrx.c

@@ -229,6 +229,12 @@ static void epping_stop_adapter(epping_adapter_t *pAdapter)
 {
 	qdf_device_t qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
 
+	if (!qdf_ctx) {
+		EPPING_LOG(QDF_TRACE_LEVEL_FATAL,
+			   "%s: qdf_ctx is NULL\n", __func__);
+		return;
+	}
+
 	if (pAdapter && pAdapter->started) {
 		EPPING_LOG(LOG1, FL("Disabling queues"));
 		netif_tx_disable(pAdapter->dev);
@@ -243,10 +249,16 @@ static int epping_start_adapter(epping_adapter_t *pAdapter)
 {
 	qdf_device_t qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
 
+	if (!qdf_ctx) {
+		EPPING_LOG(QDF_TRACE_LEVEL_FATAL,
+			   "%s: qdf_ctx is NULL", __func__);
+		return -EINVAL;
+	}
+
 	if (!pAdapter) {
 		EPPING_LOG(QDF_TRACE_LEVEL_FATAL,
 			   "%s: pAdapter= NULL\n", __func__);
-		return -1;
+		return -EINVAL;
 	}
 	if (!pAdapter->started) {
 		pld_request_bus_bandwidth(qdf_ctx->dev,