Bladeren bron

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)
Sachin Ahuja 8 jaren geleden
bovenliggende
commit
02dd2e71c5
2 gewijzigde bestanden met toevoegingen van 9 en 0 verwijderingen
  1. 1 0
      core/hdd/inc/wlan_hdd_main.h
  2. 8 0
      core/hdd/src/wlan_hdd_memdump.c

+ 1 - 0
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;

+ 8 - 0
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)) {