From a3f672fd4d5f234f9b7f2a0dbd38fdaef03f11e3 Mon Sep 17 00:00:00 2001 From: Rajeev Kumar Date: Thu, 16 Feb 2017 13:59:37 -0800 Subject: [PATCH] qcacld-3.0: Properly handle failures after pre-enable during module start In hdd_wlan_start_modules() failures after cds_pre_enable are not handled properly, this leads to freed data structures access during next module start because driver state is still set to opened state. Add fix to properly handle failures after cds_pre_enable by 1st doing cds_post_disable such that FW is PDEV suspended, SoC is reset, ce tasklets are killed and interrupts are disabled before calling cds_close() because cds_close() frees host posted buffers to FW and if FW is not PDEV suspended and host frees posted buffers this can lead to SNOC errors and unknown HLOS memory corruptions. Also change the driver state to closed state before doing cds_close such that when next hdd_wlan_start_modules() comes then driver gets re-opened and re-enabled properly. Change-Id: I5abfa3c782480d130d7fd3f9087f7a071e4a3f70 CRs-Fixed: 2007845 --- core/hdd/src/wlan_hdd_main.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 9ae0c4e27f3e..fbbf31a963ac 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -2083,15 +2083,15 @@ int hdd_wlan_start_modules(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter, if (reinit) { if (hdd_ipa_uc_ssr_reinit(hdd_ctx)) { hdd_err("HDD IPA UC reinit failed"); - goto close; + goto post_disable; } } /* Fall through dont add break here */ case DRIVER_MODULES_OPENED: if (!adapter) { - hdd_err("adapter is Null"); - goto close; + hdd_alert("adapter is Null"); + goto post_disable; } if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { hdd_err("in ftm mode, no need to configure cds modules"); @@ -2099,7 +2099,7 @@ int hdd_wlan_start_modules(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter, } if (hdd_configure_cds(hdd_ctx, adapter)) { hdd_err("Failed to Enable cds modules"); - goto close; + goto post_disable; } hdd_enable_power_management(); hdd_info("Driver Modules Successfully Enabled"); @@ -2118,7 +2118,11 @@ int hdd_wlan_start_modules(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter, EXIT(); return 0; +post_disable: + cds_post_disable(hdd_ctx->pcds_context); + close: + hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; cds_close(hdd_ctx->hdd_psoc, p_cds_context); ol_cds_free: @@ -2133,6 +2137,7 @@ release_lock: hdd_ctx->start_modules_in_progress = false; mutex_unlock(&hdd_ctx->iface_change_lock); EXIT(); + return -EINVAL; }