Răsfoiți Sursa

qcacld-3.0: Fix memory leak for sap_ctx in SSR

sap_ctx is leaked in SSR test, step as:
1.1 wlan1 is added by __wlan_hdd_add_virtual_intf for sap.
1.2 sap_ctx is created  in __wlan_hdd_add_virtual_intf->hdd_start_adapter.
1.3 ssr happens just after creating wlan1 but without open it.
1.4 no interface is opened by checking hdd_check_for_opened_interfaces,
    then iface_idle_work(hdd_iface_change_callback) is scheduled when
    stop sta interface.

As sap_ctx is still used for sap restart in SSR. So release it
once all the interfaces are down.

Change-Id: I1a522818f3e505d6aa828058cb585d8f07690824
CRs-Fixed: 2389030
Jingxiang Ge 6 ani în urmă
părinte
comite
3de02755d7

+ 16 - 0
core/hdd/src/wlan_hdd_hostapd.c

@@ -3147,6 +3147,22 @@ bool hdd_sap_destroy_ctx(struct hdd_adapter *adapter)
 	return true;
 }
 
+void hdd_sap_destroy_ctx_all(struct hdd_context *hdd_ctx, bool is_ssr)
+{
+	struct hdd_adapter *adapter;
+
+	/* sap_ctx is not destroyed as it will be leveraged for sap restart */
+	if (is_ssr)
+		return;
+
+	hdd_debug("destroying all the sap context");
+
+	hdd_for_each_adapter(hdd_ctx, adapter) {
+		if (adapter->device_mode == QDF_SAP_MODE)
+			hdd_sap_destroy_ctx(adapter);
+	}
+}
+
 QDF_STATUS hdd_init_ap_mode(struct hdd_adapter *adapter, bool reinit)
 {
 	struct hdd_hostapd_state *phostapdBuf;

+ 13 - 0
core/hdd/src/wlan_hdd_hostapd.h

@@ -151,6 +151,19 @@ bool hdd_sap_create_ctx(struct hdd_adapter *adapter);
  * Return: true or false based on overall success or failure
  */
 bool hdd_sap_destroy_ctx(struct hdd_adapter *adapter);
+/**
+ * hdd_sap_destroy_ctx_all() - Wrapper API to destroy all SAP context
+ * @adapter: pointer to adapter
+ * @is_ssr: true if SSR is in progress
+ *
+ * This wrapper API can be called to destroy all the sap context.
+ * if is_ssr is true, it will return as sap_ctx will be used when
+ * restart sap.
+ *
+ * Return: none
+ */
+void hdd_sap_destroy_ctx_all(struct hdd_context *hdd_ctx, bool is_ssr);
+
 int hdd_hostapd_stop(struct net_device *dev);
 int hdd_sap_context_init(struct hdd_context *hdd_ctx);
 void hdd_sap_context_destroy(struct hdd_context *hdd_ctx);

+ 2 - 0
core/hdd/src/wlan_hdd_main.c

@@ -11445,6 +11445,8 @@ int hdd_wlan_stop_modules(struct hdd_context *hdd_ctx, bool ftm_mode)
 	/* Free the cache channels of the command SET_DISABLE_CHANNEL_LIST */
 	wlan_hdd_free_cache_channels(hdd_ctx);
 
+	hdd_sap_destroy_ctx_all(hdd_ctx, is_recovery_stop);
+
 	hdd_check_for_leaks(hdd_ctx, is_recovery_stop);
 	hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT);