From 60dc2b18f1aa97675979aea478e991ca9304782c Mon Sep 17 00:00:00 2001 From: Jeff Johnson Date: Thu, 28 Sep 2017 14:56:02 -0700 Subject: [PATCH] qcacld-3.0: Fix CDS layering violation in hdd_wlan_start_modules() Currently hdd_wlan_start_modules() gets a pointer to the CDS Global Context, and then in the failure path it dereferences this pointer to call hdd_hif_close(). This is a layering violation -- HDD should not be aware of the contents of the CDS Global Context and should not be dereferencing the pointer. Modify the code to use the exported cds_get_context() API to retrieve this information. Change-Id: I640bea70b50d5533afa1ee1b2e0cd6b9619a4ac2 CRs-Fixed: 2118692 --- core/hdd/src/wlan_hdd_main.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 66d6d9303f28..dfff0d48f254 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -2222,27 +2222,17 @@ static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) * * Return: 0 for success; non-zero for failure */ -int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, struct hdd_adapter *adapter, +int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, + struct hdd_adapter *adapter, bool reinit) { int ret; qdf_device_t qdf_dev; QDF_STATUS status; - p_cds_contextType p_cds_context; bool unint = false; void *hif_ctx; - ENTER(); - - p_cds_context = cds_get_global_context(); - if (!p_cds_context) { - hdd_err("Global Context is NULL"); - QDF_ASSERT(0); - return -EINVAL; - } - - hdd_debug("start modules called in state! :%d reinit: %d", - hdd_ctx->driver_status, reinit); + hdd_debug("state:%d reinit:%d", hdd_ctx->driver_status, reinit); qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); if (!qdf_dev) { @@ -2400,7 +2390,8 @@ ol_cds_free: ol_cds_free(); hif_close: - hdd_hif_close(hdd_ctx, p_cds_context->pHIFContext); + hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); + hdd_hif_close(hdd_ctx, hif_ctx); power_down: if (!reinit && !unint) pld_power_off(qdf_dev->dev);