mt7615_mac_sta_poll() tests its local copy of sta_poll_list and reads the first entry without sta_poll_lock, while a station removal takes the wcid off that list under the lock. If the removal takes the last station between the two reads, the poll takes the list head for a station and writes its airtime counters to the stack. Test the list and take the station off it in one locked section. Fixes: a621372a04ac ("mt76: mt7615: rework mt7615_mac_sta_poll for usb code") Signed-off-by: Felix Fietkau --- drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c index ada40b8a517a..8e81ebe3e2ca 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c @@ -905,13 +905,16 @@ void mt7615_mac_sta_poll(struct mt7615_dev *dev) list_splice_init(&dev->mt76.sta_poll_list, &sta_poll_list); spin_unlock_bh(&dev->mt76.sta_poll_lock); - while (!list_empty(&sta_poll_list)) { + while (true) { bool clear = false; + spin_lock_bh(&dev->mt76.sta_poll_lock); + if (list_empty(&sta_poll_list)) { + spin_unlock_bh(&dev->mt76.sta_poll_lock); + break; + } msta = list_first_entry(&sta_poll_list, struct mt7615_sta, wcid.poll_list); - - spin_lock_bh(&dev->mt76.sta_poll_lock); list_del_init(&msta->wcid.poll_list); spin_unlock_bh(&dev->mt76.sta_poll_lock); -- 2.47.3