From c99fa7f76ff4418333ea2f06c8d0ae9f3dd95051 Mon Sep 17 00:00:00 2001 From: tinlin Date: Fri, 20 Sep 2019 10:43:50 +0800 Subject: [PATCH] qcacld-3.0: Fix possible null pointer dereference roam_info may be null pointer and be explicitly dereferenced when roam_status is eCSR_ROAM_LOSTLINK in hdd_dis_connect_hanler. Add null check for roam_info before getting roam_info->reasonCode. Change-Id: I11be7b722921a9be8ed1419251f6cbf19506a11d CRs-Fixed: 2531563 --- core/hdd/src/wlan_hdd_assoc.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/core/hdd/src/wlan_hdd_assoc.c b/core/hdd/src/wlan_hdd_assoc.c index ccc5e91ed025b..281000d378284 100644 --- a/core/hdd/src/wlan_hdd_assoc.c +++ b/core/hdd/src/wlan_hdd_assoc.c @@ -1759,6 +1759,8 @@ static QDF_STATUS hdd_dis_connect_handler(struct hdd_adapter *adapter, * by kernel */ if (sendDisconInd) { + int reason = WLAN_REASON_UNSPECIFIED; + if (roam_info && roam_info->disconnect_ies) { disconnect_ies.data = roam_info->disconnect_ies->data; @@ -1769,28 +1771,21 @@ static QDF_STATUS hdd_dis_connect_handler(struct hdd_adapter *adapter, * To avoid wpa_supplicant sending "HANGED" CMD * to ICS UI. */ - if (eCSR_ROAM_LOSTLINK == roam_status) { - if (roam_info && roam_info->reasonCode == + if (roam_info && eCSR_ROAM_LOSTLINK == roam_status) { + reason = roam_info->reasonCode; + if (reason == eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON) pr_info("wlan: disconnected due to poor signal, rssi is %d dB\n", roam_info->rxRssi); - wlan_hdd_cfg80211_indicate_disconnect( - dev, false, - roam_info->reasonCode, - disconnect_ies.data, - disconnect_ies.len); - } else { - wlan_hdd_cfg80211_indicate_disconnect( - dev, false, - WLAN_REASON_UNSPECIFIED, - disconnect_ies.data, - disconnect_ies.len); } + wlan_hdd_cfg80211_indicate_disconnect( + dev, false, + reason, + disconnect_ies.data, + disconnect_ies.len); hdd_debug("sent disconnected event to nl80211, reason code %d", - (eCSR_ROAM_LOSTLINK == roam_status) ? - roam_info->reasonCode : - WLAN_REASON_UNSPECIFIED); + reason); } /* update P2P connection status */