qcacld-3.0: Fix memory leaks detected in pending_event list

Pending_event memory is dynamically allocated after driver loaded
but freed up only when driver unloading.
Fix to free pending_event memory when driver stop.

Change-Id: Ia748e311fc77fc99e193230910fccd7bc9b4f5a9
CRs-Fixed: 2126695
diff --git a/core/hdd/src/wlan_hdd_ipa.c b/core/hdd/src/wlan_hdd_ipa.c
index 5dbe66f..cc21216 100644
--- a/core/hdd/src/wlan_hdd_ipa.c
+++ b/core/hdd/src/wlan_hdd_ipa.c
@@ -2878,6 +2878,21 @@
 }
 
 /**
+ * hdd_ipa_cleanup_pending_event() - Cleanup IPA pending event list
+ * @hdd_ipa: pointer to HDD IPA struct
+ *
+ * Return: none
+ */
+static void hdd_ipa_cleanup_pending_event(struct hdd_ipa_priv *hdd_ipa)
+{
+	struct ipa_uc_pending_event *pending_event = NULL;
+
+	while (qdf_list_remove_front(&hdd_ipa->pending_event,
+		(qdf_list_node_t **)&pending_event) == QDF_STATUS_SUCCESS)
+		qdf_mem_free(pending_event);
+}
+
+/**
  * hdd_ipa_uc_ol_deinit() - Disconnect IPA TX and RX pipes
  * @hdd_ctx: Global HDD context
  *
@@ -2909,6 +2924,8 @@
 		}
 	}
 
+	hdd_ipa_cleanup_pending_event(hdd_ipa);
+
 	HDD_IPA_LOG(QDF_TRACE_LEVEL_FATAL, "exit: ret=%d", ret);
 	return ret;
 }
@@ -5663,24 +5680,6 @@
 
 
 /**
- * hdd_ipa_cleanup_pending_event() - Cleanup IPA pending event list
- * @hdd_ipa: pointer to HDD IPA struct
- *
- * Return: none
- */
-static void hdd_ipa_cleanup_pending_event(struct hdd_ipa_priv *hdd_ipa)
-{
-	struct ipa_uc_pending_event *pending_event = NULL;
-
-	while (qdf_list_remove_front(&hdd_ipa->pending_event,
-		(qdf_list_node_t **)&pending_event) == QDF_STATUS_SUCCESS) {
-		qdf_mem_free(pending_event);
-	}
-
-	qdf_list_destroy(&hdd_ipa->pending_event);
-}
-
-/**
  * __hdd_ipa_flush - flush IPA exception path SKB's
  * @hdd_ctx: HDD global context
  *
@@ -5756,7 +5755,7 @@
 		hdd_ipa_uc_rt_debug_deinit(hdd_ctx);
 		qdf_mutex_destroy(&hdd_ipa->event_lock);
 		qdf_mutex_destroy(&hdd_ipa->ipa_lock);
-		hdd_ipa_cleanup_pending_event(hdd_ipa);
+		qdf_list_destroy(&hdd_ipa->pending_event);
 
 		for (i = 0; i < HDD_IPA_UC_OPCODE_MAX; i++) {
 			cancel_work_sync(&hdd_ipa->uc_op_work[i].work);