diff mbox series

[wireless] wifi: mt76: mt7615: fix possible race in mt7615_mac_sta_poll

Message ID 48b23404b759de4f1db2ef85975c72a4aeb1097c.1684938695.git.lorenzo@kernel.org (mailing list archive)
State Accepted
Commit 30bc32c7c1f975cc3c14e1c7dc437266311282cf
Delegated to: Kalle Valo
Headers show
Series [wireless] wifi: mt76: mt7615: fix possible race in mt7615_mac_sta_poll | expand

Commit Message

Lorenzo Bianconi May 24, 2023, 2:39 p.m. UTC
Grab sta_poll_lock spinlock in mt7615_mac_sta_poll routine in order to
avoid possible races with mt7615_mac_add_txs() or mt7615_mac_fill_rx()
removing msta pointer from sta_poll_list.

Fixes: a621372a04ac ("mt76: mt7615: rework mt7615_mac_sta_poll for usb code")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Kalle Valo May 25, 2023, 5:55 a.m. UTC | #1
Lorenzo Bianconi <lorenzo@kernel.org> writes:

> Grab sta_poll_lock spinlock in mt7615_mac_sta_poll routine in order to
> avoid possible races with mt7615_mac_add_txs() or mt7615_mac_fill_rx()
> removing msta pointer from sta_poll_list.
>
> Fixes: a621372a04ac ("mt76: mt7615: rework mt7615_mac_sta_poll for usb code")
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>

I'll take this to wireless tree.
Kalle Valo May 27, 2023, 8:17 a.m. UTC | #2
Lorenzo Bianconi <lorenzo@kernel.org> wrote:

> Grab sta_poll_lock spinlock in mt7615_mac_sta_poll routine in order to
> avoid possible races with mt7615_mac_add_txs() or mt7615_mac_fill_rx()
> removing msta pointer from sta_poll_list.
> 
> Fixes: a621372a04ac ("mt76: mt7615: rework mt7615_mac_sta_poll for usb code")
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>

Patch applied to wireless.git, thanks.

30bc32c7c1f9 wifi: mt76: mt7615: fix possible race in mt7615_mac_sta_poll
diff mbox series

Patch

diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
index da1d17b73a25..64002484ccad 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
@@ -914,7 +914,10 @@  void mt7615_mac_sta_poll(struct mt7615_dev *dev)
 
 		msta = list_first_entry(&sta_poll_list, struct mt7615_sta,
 					poll_list);
+
+		spin_lock_bh(&dev->sta_poll_lock);
 		list_del_init(&msta->poll_list);
+		spin_unlock_bh(&dev->sta_poll_lock);
 
 		addr = mt7615_mac_wtbl_addr(dev, msta->wcid.idx) + 19 * 4;