From 11bc67c606efc6928a062aa7694c3658b46acae5 Mon Sep 17 00:00:00 2001 From: gaurank kathpalia Date: Mon, 26 Aug 2019 12:44:40 +0530 Subject: [PATCH] qcacld-3.0: Clear sap ctx channel list in undo acs Currently the sap ctx's channel list is not freed as part of undo acs, and hence can lead to mem leak when the do acs and SSR is triggered in parallel. Scenario:- 1. Turn on SAP 2. Do SSR in parallel 3. Unload WLAN Fix is to clear the channel list as part of undo acs. Change-Id: Ie8dcace1d32aeec2621e785d793290d70c194f62 CRs-Fixed: 2511752 --- core/hdd/src/wlan_hdd_cfg80211.c | 21 +-------------------- core/sap/inc/sap_api.h | 11 +++++++++++ core/sap/src/sap_module.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 20 deletions(-) diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index d9187c842115..d1f5998b42c7 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -3027,28 +3027,9 @@ static int wlan_hdd_cfg80211_do_acs(struct wiphy *wiphy, * * Return: void */ - void wlan_hdd_undo_acs(struct hdd_adapter *adapter) { - struct sap_config *sap_cfg; - - if (!adapter) - return; - - sap_cfg = &adapter->session.ap.sap_config; - if (sap_cfg->acs_cfg.ch_list) { - hdd_debug("Clearing ACS cfg channel list"); - qdf_mem_free(sap_cfg->acs_cfg.ch_list); - sap_cfg->acs_cfg.ch_list = NULL; - } - if (sap_cfg->acs_cfg.master_ch_list) { - hdd_debug("Clearing master ACS cfg channel list"); - qdf_mem_free(sap_cfg->acs_cfg.master_ch_list); - sap_cfg->acs_cfg.master_ch_list = NULL; - } - sap_cfg->acs_cfg.ch_list_count = 0; - sap_cfg->acs_cfg.master_ch_list_count = 0; - sap_cfg->acs_cfg.acs_mode = false; + sap_undo_acs(WLAN_HDD_GET_SAP_CTX_PTR(adapter)); } /** diff --git a/core/sap/inc/sap_api.h b/core/sap/inc/sap_api.h index 4165aca8ecd8..7743ed49d401 100644 --- a/core/sap/inc/sap_api.h +++ b/core/sap/inc/sap_api.h @@ -1322,6 +1322,17 @@ QDF_STATUS wlansap_acs_chselect(struct sap_context *sap_context, struct sap_config *config, void *pusr_context); +/** + * sap_undo_acs() - Undo acs i.e free the allocated ch lists + * @sap_ctx: pointer to the SAP context + * + * This function will free the memory allocated to the sap ctx channel list, acs + * cfg ch list and master ch list. + * + * Return: None + */ +void sap_undo_acs(struct sap_context *sap_context); + /** * wlansap_get_chan_width() - get sap channel width. * @sap_ctx: pointer to the SAP context diff --git a/core/sap/src/sap_module.c b/core/sap/src/sap_module.c index 652152fd6cc7..6df631313674 100644 --- a/core/sap/src/sap_module.c +++ b/core/sap/src/sap_module.c @@ -2482,6 +2482,38 @@ void wlansap_populate_del_sta_params(const uint8_t *mac, QDF_MAC_ADDR_ARRAY(params->peerMacAddr.bytes)); } +void sap_undo_acs(struct sap_context *sap_ctx) +{ + struct sap_acs_cfg *acs_cfg; + + if (!sap_ctx) + return; + + acs_cfg = sap_ctx->acs_cfg; + if (!acs_cfg) + return; + + if (acs_cfg->ch_list) { + sap_debug("Clearing ACS cfg channel list"); + qdf_mem_free(acs_cfg->ch_list); + acs_cfg->ch_list = NULL; + } + if (acs_cfg->master_ch_list) { + sap_debug("Clearing master ACS cfg channel list"); + qdf_mem_free(acs_cfg->master_ch_list); + acs_cfg->master_ch_list = NULL; + } + if (sap_ctx->freq_list) { + sap_debug("Clearing sap context ch freq list"); + qdf_mem_free(sap_ctx->freq_list); + sap_ctx->freq_list = NULL; + } + acs_cfg->ch_list_count = 0; + acs_cfg->master_ch_list_count = 0; + acs_cfg->acs_mode = false; + sap_ctx->num_of_channel = 0; +} + QDF_STATUS wlansap_acs_chselect(struct sap_context *sap_context, sap_event_cb acs_event_callback, struct sap_config *config,