diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index d9187c8421..d1f5998b42 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 4165aca8ec..7743ed49d4 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 652152fd6c..6df6313136 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,