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
This commit is contained in:
hangtian 2019-06-11 11:53:50 +08:00 committed by nshrivas
parent 2dbc844a87
commit 821d12dbf5
2 changed files with 21 additions and 2 deletions

View File

@ -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);

View File

@ -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;