From 46d26b7fcfd6d4f3536ae1f85675a493a6d601a1 Mon Sep 17 00:00:00 2001 From: Rajeev Kumar Date: Tue, 7 Jun 2016 13:32:10 -0700 Subject: [PATCH] qcacld-3.0: Fix race condition between scan and SSR/driver unload HDD validate context check is at wrong place in __wlan_hdd_cfg80211_scan() which is leading to invalid pointer access and page fault. Move HDD validate context check at begining of scan API to avoid accessing any context pointer which is getting freed during SSR/driver unload. Change-Id: Id91c9ea54c513ecc25bdf42904a5bb5cde2e91ce CRs-Fixed: 1025498 --- core/hdd/src/wlan_hdd_scan.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/hdd/src/wlan_hdd_scan.c b/core/hdd/src/wlan_hdd_scan.c index 0e641ffc09a3..f5767944e6db 100644 --- a/core/hdd/src/wlan_hdd_scan.c +++ b/core/hdd/src/wlan_hdd_scan.c @@ -1271,6 +1271,11 @@ static int __wlan_hdd_cfg80211_scan(struct wiphy *wiphy, return -EINVAL; } + status = wlan_hdd_validate_context(pHddCtx); + + if (0 != status) + return status; + MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_CFG80211_SCAN, pAdapter->sessionId, request->n_channels)); @@ -1282,10 +1287,6 @@ static int __wlan_hdd_cfg80211_scan(struct wiphy *wiphy, hdd_device_mode_to_string(pAdapter->device_mode), pAdapter->device_mode); - status = wlan_hdd_validate_context(pHddCtx); - - if (0 != status) - return status; cfg_param = pHddCtx->config; pScanInfo = &pAdapter->scan_info;