@@ -11056,6 +11056,7 @@ static void ath12k_mac_op_sta_statistics(struct ieee80211_hw *hw,
db2dbm = test_bit(WMI_TLV_SERVICE_HW_DB2DBM_CONVERSION_SUPPORT,
ar->ab->wmi_ab.svc_map);
+ spin_lock_bh(&ar->ab->base_lock);
sinfo->rx_duration = arsta->rx_duration;
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_DURATION);
@@ -11097,6 +11098,7 @@ static void ath12k_mac_op_sta_statistics(struct ieee80211_hw *hw,
}
sinfo->signal_avg = ewma_avg_rssi_read(&arsta->avg_rssi);
+ spin_unlock_bh(&ar->ab->base_lock);
if (!db2dbm)
sinfo->signal_avg += ATH12K_DEFAULT_NOISE_FLOOR;
@@ -7524,7 +7524,9 @@ static int ath12k_wmi_tlv_fw_stats_data_parse(struct ath12k_base *ab,
if (sta) {
ahsta = ath12k_sta_to_ahsta(sta);
arsta = &ahsta->deflink;
+ spin_lock_bh(&ab->base_lock);
arsta->rssi_beacon = le32_to_cpu(src->beacon_snr);
+ spin_unlock_bh(&ab->base_lock);
ath12k_dbg(ab, ATH12K_DBG_WMI,
"wmi stats vdev id %d snr %d\n",
src->vdev_id, src->beacon_snr);
The ab->base_lock spinlock is being used while updating the arsta TX rate statistics and other fields like rssi/rx/tx_duration. But these fields are accessed in ath12k_mac_op_sta_statistics() without any lock protection, which can lead to reading incorrect or partially updated values. To prevent this race condition and avoid the inconsistency, the same spinlock should also be used when accessing these statistics in ath12k_mac_op_sta_statistics() Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1 Signed-off-by: Tamizh Chelvam Raja <tamizh.raja@oss.qualcomm.com> --- drivers/net/wireless/ath/ath12k/mac.c | 2 ++ drivers/net/wireless/ath/ath12k/wmi.c | 2 ++ 2 files changed, 4 insertions(+) base-commit: 535de528015b56e34a40a8e1eb1629fadf809a84