b37f070ba644322836c2a0eae95f60291b8daac7
[openwrt/staging/hauke.git] / package / kernel / mac80211 / patches / ath11k / 0036-wifi-ath11k-fix-SAC-bug-on-peer-addition-with-sta-ba.patch
1 From 60b7d62ba8cdbd073997bff0f1cdae8d844002c0 Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Thu, 9 Feb 2023 23:26:22 +0100
4 Subject: [PATCH] wifi: ath11k: fix SAC bug on peer addition with sta band
5 migration
6
7 Fix sleep in atomic context warning detected by Smatch static checker
8 analyzer.
9
10 Following the locking pattern for peer_rhash_add lock tbl_mtx_lock mutex
11 always even if sta is not transitioning to another band.
12 This is peer_add function and a more secure locking should not cause
13 performance regression.
14
15 Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.5.0.1-01208-QCAHKSWPL_SILICONZ-1
16
17 Fixes: d673cb6fe6c0 ("wifi: ath11k: fix peer addition/deletion error on sta band migration")
18 Reported-by: Dan Carpenter <error27@gmail.com>
19 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
20 Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
21 Link: https://lore.kernel.org/r/20230209222622.1751-1-ansuelsmth@gmail.com
22 ---
23 drivers/net/wireless/ath/ath11k/peer.c | 5 +++--
24 1 file changed, 3 insertions(+), 2 deletions(-)
25
26 --- a/drivers/net/wireless/ath/ath11k/peer.c
27 +++ b/drivers/net/wireless/ath/ath11k/peer.c
28 @@ -382,22 +382,23 @@ int ath11k_peer_create(struct ath11k *ar
29 return -ENOBUFS;
30 }
31
32 + mutex_lock(&ar->ab->tbl_mtx_lock);
33 spin_lock_bh(&ar->ab->base_lock);
34 peer = ath11k_peer_find_by_addr(ar->ab, param->peer_addr);
35 if (peer) {
36 if (peer->vdev_id == param->vdev_id) {
37 spin_unlock_bh(&ar->ab->base_lock);
38 + mutex_unlock(&ar->ab->tbl_mtx_lock);
39 return -EINVAL;
40 }
41
42 /* Assume sta is transitioning to another band.
43 * Remove here the peer from rhash.
44 */
45 - mutex_lock(&ar->ab->tbl_mtx_lock);
46 ath11k_peer_rhash_delete(ar->ab, peer);
47 - mutex_unlock(&ar->ab->tbl_mtx_lock);
48 }
49 spin_unlock_bh(&ar->ab->base_lock);
50 + mutex_unlock(&ar->ab->tbl_mtx_lock);
51
52 ret = ath11k_wmi_send_peer_create_cmd(ar, param);
53 if (ret) {