From 8215fde26bd290b4c8c65f35721c71dbaafc7a7c Mon Sep 17 00:00:00 2001 From: hangtian Date: Wed, 10 Jul 2019 12:27:19 +0800 Subject: [PATCH] qcacld-3.0: Validate wdev before accessing netdev Validate wdev before accessing netdev in __wlan_hdd_cfg80211_set_txpower. Avoid invalid memory access. Change-Id: I48af4e458ef7571cfdf9f157cdb8c3427fff4fc7 CRs-Fixed: 2487005 --- core/hdd/src/wlan_hdd_power.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/hdd/src/wlan_hdd_power.c b/core/hdd/src/wlan_hdd_power.c index 48cddd1ea0e0..bc3c021d8cc0 100644 --- a/core/hdd/src/wlan_hdd_power.c +++ b/core/hdd/src/wlan_hdd_power.c @@ -2020,7 +2020,7 @@ static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy, { struct hdd_context *hdd_ctx = (struct hdd_context *) wiphy_priv(wiphy); mac_handle_t mac_handle; - struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(wdev->netdev); + struct hdd_adapter *adapter; struct qdf_mac_addr bssid = QDF_MAC_ADDR_BCAST_INIT; struct qdf_mac_addr selfmac; QDF_STATUS status; @@ -2029,6 +2029,13 @@ static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy, hdd_enter(); + if (!wdev) { + hdd_err("wdev is null, set tx power failed"); + return -EIO; + } + + adapter = WLAN_HDD_GET_PRIV_PTR(wdev->netdev); + if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { hdd_err("Command not allowed in FTM mode"); return -EINVAL;