From fed7e28e4e720ee22c9d8874f5b091b2fb60bb62 Mon Sep 17 00:00:00 2001 From: sheenam monga Date: Wed, 7 Aug 2019 15:48:21 +0530 Subject: [PATCH] qcacld-3.0: Return success status in case stop_ap command after SSR In case Device is P2P GO and SSR is triggered due to any reason, Stop_adapter is called. Inside stop adapter adapter->session.ap.beacon is freed. When P2P GO negotiation is initiated after SSR, __wlan_hdd_cfg80211_stop_ap function tries to access adapter->session.ap.beacon which freed during SSR. Failure is returned in case adapter->session.ap.beacon is NULL, Which causes failure of p2p negotiation. Fix is to return success to upper layers in case SAP is already down, So that beacon interval can be cleaned up. Change-Id: Ie7a30475b2a54860843b1430964585d22f02c110 CRs-Fixed: 2503216 --- core/hdd/src/wlan_hdd_hostapd.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/core/hdd/src/wlan_hdd_hostapd.c b/core/hdd/src/wlan_hdd_hostapd.c index ca59f01b4544..a4fef6be079c 100644 --- a/core/hdd/src/wlan_hdd_hostapd.c +++ b/core/hdd/src/wlan_hdd_hostapd.c @@ -5676,10 +5676,9 @@ static int __wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy, { struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); struct hdd_context *hdd_ctx = wiphy_priv(wiphy); - QDF_STATUS status = QDF_STATUS_E_FAILURE; + QDF_STATUS status; QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE; tSirUpdateIE update_ie; - struct hdd_beacon_data *old; int ret; mac_handle_t mac_handle; @@ -5753,12 +5752,6 @@ static int __wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy, WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, WLAN_CONTROL_PATH); - old = adapter->session.ap.beacon; - if (!old) { - hdd_err("Session id: %d beacon data points to NULL", - adapter->vdev_id); - return -EINVAL; - } wlan_hdd_cleanup_actionframe(adapter); wlan_hdd_cleanup_remain_on_channel_ctx(adapter); mutex_lock(&hdd_ctx->sap_lock); @@ -5788,9 +5781,17 @@ static int __wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy, adapter->vdev_id); hdd_green_ap_start_state_mc(hdd_ctx, adapter->device_mode, false); - adapter->session.ap.beacon = NULL; - qdf_mem_free(old); + + if (adapter->session.ap.beacon) { + qdf_mem_free(adapter->session.ap.beacon); + adapter->session.ap.beacon = NULL; + } + } else { + hdd_debug("SAP already down"); + mutex_unlock(&hdd_ctx->sap_lock); + return 0; } + mutex_unlock(&hdd_ctx->sap_lock); mac_handle = hdd_ctx->mac_handle;