From 7ef504ef795f686c3800e54858cd7121e3247044 Mon Sep 17 00:00:00 2001 From: Manikandan Mohan Date: Fri, 17 Mar 2017 14:55:17 -0700 Subject: [PATCH] qcacld-3.0: Check for adapter validity in pre cac work Check for adapter validity for pre cac adapter close work function and hdd context validity to avoid crash during race condition in SSR case. Change-Id: I6c167e8f1a8199c63fba905fff4e781d244c7dc1 CRs-fixed: 2021403 --- core/hdd/src/wlan_hdd_hostapd.c | 57 ++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/core/hdd/src/wlan_hdd_hostapd.c b/core/hdd/src/wlan_hdd_hostapd.c index ccd3544860e0..d46412e60d24 100644 --- a/core/hdd/src/wlan_hdd_hostapd.c +++ b/core/hdd/src/wlan_hdd_hostapd.c @@ -890,6 +890,40 @@ static int wlan_hdd_set_pre_cac_complete_status(hdd_adapter_t *ap_adapter, return 0; } +/** + * __wlan_hdd_sap_pre_cac_failure() - Process the pre cac failure + * @data: AP adapter + * + * Deletes the pre cac adapter + * + * Return: None + */ +static void __wlan_hdd_sap_pre_cac_failure(void *data) +{ + hdd_adapter_t *adapter; + hdd_context_t *hdd_ctx; + + ENTER(); + + adapter = (hdd_adapter_t *) data; + if (!adapter || + adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { + hdd_err("SAP Pre CAC adapter invalid"); + return; + } + + hdd_ctx = (hdd_context_t *) (adapter->pHddCtx); + if (wlan_hdd_validate_context(hdd_ctx)) { + hdd_err("HDD context is null"); + return; + } + + wlan_hdd_release_intf_addr(hdd_ctx, + adapter->macAddressCurrent.bytes); + hdd_stop_adapter(hdd_ctx, adapter, true); + hdd_close_adapter(hdd_ctx, adapter, false); +} + /** * wlan_hdd_sap_pre_cac_failure() - Process the pre cac failure * @data: AP adapter @@ -900,32 +934,11 @@ static int wlan_hdd_set_pre_cac_complete_status(hdd_adapter_t *ap_adapter, */ void wlan_hdd_sap_pre_cac_failure(void *data) { - hdd_adapter_t *pHostapdAdapter; - hdd_context_t *hdd_ctx; - - ENTER(); - - pHostapdAdapter = (hdd_adapter_t *) data; - if (!pHostapdAdapter) { - hdd_err("AP adapter is NULL"); - return; - } - - hdd_ctx = (hdd_context_t *) (pHostapdAdapter->pHddCtx); - if (!hdd_ctx) { - hdd_err("HDD context is null"); - return; - } - cds_ssr_protect(__func__); - wlan_hdd_release_intf_addr(hdd_ctx, - pHostapdAdapter->macAddressCurrent.bytes); - hdd_stop_adapter(hdd_ctx, pHostapdAdapter, true); - hdd_close_adapter(hdd_ctx, pHostapdAdapter, false); + __wlan_hdd_sap_pre_cac_failure(data); cds_ssr_unprotect(__func__); } - /** * wlan_hdd_sap_pre_cac_success() - Process the pre cac result * @data: AP adapter