From 02dd2e71c5fefa3cece9253fee9f9dffb7a3ed5e Mon Sep 17 00:00:00 2001 From: Sachin Ahuja Date: Sat, 3 Sep 2016 16:17:51 +0530 Subject: qcacld-3.0: Deinit memdump only when it is initialized During driver initialization, if hif_register_driver timeout then memdump is not initialized. Due to this timeout, unregister driver is called which deinitialize memdump which cause crash as uninitialized mutex is accessed in memdump_deinit. To fix this issue, deinit memdump only when the init is successful. Change-Id: I781717a2a160aa09c9f60ebface1238507d1a623 CRs-Fixed: 991443 (cherry picked from commit 54eda9379d7dec74ac6c3efd1659dffdd32c0680) --- core/hdd/inc/wlan_hdd_main.h | 1 + core/hdd/src/wlan_hdd_memdump.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/core/hdd/inc/wlan_hdd_main.h b/core/hdd/inc/wlan_hdd_main.h index 38bac4b2ce5a..94f1eb0dbe3b 100644 --- a/core/hdd/inc/wlan_hdd_main.h +++ b/core/hdd/inc/wlan_hdd_main.h @@ -1442,6 +1442,7 @@ struct hdd_context_s { qdf_mc_timer_t memdump_cleanup_timer; struct mutex memdump_lock; bool memdump_in_progress; + bool memdump_init_done; #endif /* WLAN_FEATURE_MEMDUMP */ bool connection_in_progress; diff --git a/core/hdd/src/wlan_hdd_memdump.c b/core/hdd/src/wlan_hdd_memdump.c index b6a3ccb1f9c8..1afe3fd7569c 100644 --- a/core/hdd/src/wlan_hdd_memdump.c +++ b/core/hdd/src/wlan_hdd_memdump.c @@ -565,6 +565,7 @@ int memdump_init(void) } mutex_init(&hdd_ctx->memdump_lock); + hdd_ctx->memdump_init_done = true; return 0; } @@ -595,6 +596,12 @@ void memdump_deinit(void) return; } + if (!hdd_ctx->memdump_init_done) { + hdd_err("MemDump not initialized"); + return; + } + hdd_ctx->memdump_init_done = false; + qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); if (!qdf_ctx) { hdd_err("QDF context is NULL"); @@ -612,6 +619,7 @@ void memdump_deinit(void) hdd_ctx->memdump_in_progress = false; } mutex_unlock(&hdd_ctx->memdump_lock); + mutex_destroy(&hdd_ctx->memdump_lock); if (QDF_TIMER_STATE_RUNNING == qdf_mc_timer_get_current_state(&hdd_ctx->memdump_cleanup_timer)) { -- cgit v1.2.3