From e9068f16909112b9ecbf2d421a5eeba9ad30cbed Mon Sep 17 00:00:00 2001 From: Abhishek Singh Date: Fri, 31 Mar 2017 14:14:52 +0530 Subject: [PATCH] qcacld-3.0: Fix psoc's use after psoc destroy psoc is allocated during start module and destroy in stop modules. due to this if psoc is used after stop modules it cause crash. psoc should be the first thing to get allocated and last thing to get destroyed. Fix it by calling psoc destroy at the ned of the wlan exit and allocating in wlan start. Change-Id: I969a5688751ddfad9ab9c3152e6af0680d2be605 CRs-Fixed: 2027351 --- core/hdd/src/wlan_hdd_main.c | 38 +++++++++++++++++------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 0deeed7bcc..d9f77c1e4c 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -2003,17 +2003,10 @@ int hdd_wlan_start_modules(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter, goto hif_close; } - ret = hdd_objmgr_create_and_store_psoc(hdd_ctx, - DEFAULT_PSOC_ID); - if (ret) { - hdd_err("Psoc creation fails!"); - goto ol_cds_free; - } - ret = hdd_update_config(hdd_ctx); if (ret) { hdd_err("Failed to update configuration :%d", ret); - goto destroy_psoc_object; + goto ol_cds_free; } hdd_update_cds_ac_specs_params(hdd_ctx); @@ -2021,7 +2014,7 @@ int hdd_wlan_start_modules(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter, status = cds_open(hdd_ctx->hdd_psoc); if (!QDF_IS_STATUS_SUCCESS(status)) { hdd_err("Failed to Open CDS: %d", status); - goto destroy_psoc_object; + goto ol_cds_free; } /* initalize components configurations after psoc open */ @@ -2097,9 +2090,6 @@ int hdd_wlan_start_modules(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter, close: cds_close(hdd_ctx->hdd_psoc, p_cds_context); -destroy_psoc_object: - hdd_objmgr_release_and_destroy_psoc(hdd_ctx); - ol_cds_free: ol_cds_free(); @@ -5403,6 +5393,14 @@ static void hdd_wlan_exit(hdd_context_t *hdd_ctx) hdd_exit_netlink_services(hdd_ctx); mutex_destroy(&hdd_ctx->iface_change_lock); + + driver_status = hdd_objmgr_release_and_destroy_pdev(hdd_ctx); + if (driver_status) + hdd_err("Pdev delete failed"); + + driver_status = hdd_objmgr_release_and_destroy_psoc(hdd_ctx); + if (driver_status) + hdd_err("Psoc delete failed"); hdd_context_destroy(hdd_ctx); } @@ -8813,14 +8811,6 @@ int hdd_wlan_stop_modules(hdd_context_t *hdd_ctx) QDF_ASSERT(0); } - ret = hdd_objmgr_release_and_destroy_pdev(hdd_ctx); - if (ret) - hdd_err("Pdev delete failed"); - - ret = hdd_objmgr_release_and_destroy_psoc(hdd_ctx); - if (ret) - hdd_err("Psoc delete failed"); - hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); if (!hif_ctx) { hdd_err("Hif context is Null"); @@ -8970,6 +8960,14 @@ int hdd_wlan_startup(struct device *dev) if (IS_ERR(hdd_ctx)) return PTR_ERR(hdd_ctx); + ret = hdd_objmgr_create_and_store_psoc(hdd_ctx, + DEFAULT_PSOC_ID); + if (ret) { + hdd_err("Psoc creation fails!"); + QDF_BUG(0); + goto err_hdd_free_context; + } + qdf_mc_timer_init(&hdd_ctx->iface_change_timer, QDF_TIMER_TYPE_SW, hdd_iface_change_callback, (void *)hdd_ctx);