From 821d12dbf51bac9518bac3e5493f14ce83057623 Mon Sep 17 00:00:00 2001 From: hangtian Date: Tue, 11 Jun 2019 11:53:50 +0800 Subject: [PATCH] qcacld-3.0: Fix cfg80211_ops.set_tx_power invalid bssid issue Fix cfg80211_ops.set_tx_power invalid bssid issue. User could set txpower via cfg80211 interface. Change-Id: Ie103a45e426b920846b8e4d23c4995ce660dde70 CRs-Fixed: 2468749 --- core/hdd/src/wlan_hdd_cfg80211.c | 1 + core/hdd/src/wlan_hdd_power.c | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index 8cb9d238700f7..1258b3a46fa72 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -13550,6 +13550,7 @@ int wlan_hdd_cfg80211_init(struct device *dev, #endif wiphy->features |= NL80211_FEATURE_INACTIVITY_TIMER; + wiphy->features |= NL80211_FEATURE_VIF_TXPOWER; #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)) || \ defined(CFG80211_BEACON_TX_RATE_CUSTOM_BACKPORT) wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_BEACON_RATE_LEGACY); diff --git a/core/hdd/src/wlan_hdd_power.c b/core/hdd/src/wlan_hdd_power.c index e68c930e66870..1b0030340ff88 100644 --- a/core/hdd/src/wlan_hdd_power.c +++ b/core/hdd/src/wlan_hdd_power.c @@ -2020,8 +2020,9 @@ 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 qdf_mac_addr bssid = QDF_MAC_ADDR_BCAST_INIT; - struct qdf_mac_addr selfMac = QDF_MAC_ADDR_BCAST_INIT; + struct qdf_mac_addr selfmac; QDF_STATUS status; int errno; int dbm; @@ -2041,6 +2042,23 @@ static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy, if (errno) return errno; + if (wlan_hdd_validate_vdev_id(adapter->vdev_id)) + return -EINVAL; + + if (adapter->device_mode == QDF_SAP_MODE || + adapter->device_mode == QDF_P2P_GO_MODE) { + qdf_copy_macaddr(&bssid, &adapter->mac_addr); + } else { + struct hdd_station_ctx *sta_ctx = + WLAN_HDD_GET_STATION_CTX_PTR(adapter); + + if (eConnectionState_Associated == + sta_ctx->conn_info.conn_state) + qdf_copy_macaddr(&bssid, &sta_ctx->conn_info.bssid); + } + + qdf_copy_macaddr(&selfmac, &adapter->mac_addr); + mac_handle = hdd_ctx->mac_handle; dbm = MBM_TO_DBM(mbm); @@ -2068,7 +2086,7 @@ static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy, /* Fall through */ case NL80211_TX_POWER_LIMITED: /* Limit TX power by the mBm parameter */ - status = sme_set_max_tx_power(mac_handle, bssid, selfMac, dbm); + status = sme_set_max_tx_power(mac_handle, bssid, selfmac, dbm); if (QDF_IS_STATUS_ERROR(status)) { hdd_err("Setting maximum tx power failed, %d", status); return -EIO;