Skip to content

Commit 91e7784

Browse files
moore-brosgregkh
authored andcommitted
wifi: mt76: mt7921: fix potential deadlock in mt7921_roc_abort_sync
[ Upstream commit d5059e5 ] roc_abort_sync() can deadlock with roc_work(). roc_work() holds dev->mt76.mutex, while cancel_work_sync() waits for roc_work() to finish. If the caller already owns the same mutex, both sides block and no progress is possible. This deadlock can occur during station removal when mt76_sta_state() -> mt76_sta_remove() -> mt7921_mac_sta_remove() -> mt7921_roc_abort_sync() invokes cancel_work_sync() while roc_work() is still running and holding dev->mt76.mutex. This avoids the mutex deadlock and preserves exactly-once work ownership. Fixes: 352d966 ("wifi: mt76: mt7921: fix a potential association failure upon resuming") Co-developed-by: Quan Zhou <quan.zhou@mediatek.com> Signed-off-by: Quan Zhou <quan.zhou@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Link: https://patch.msgid.link/20260126180013.8167-1-sean.wang@kernel.org Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent f3be831 commit 91e7784

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

  • drivers/net/wireless/mediatek/mt76/mt7921

drivers/net/wireless/mediatek/mt76/mt7921/main.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -371,12 +371,15 @@ void mt7921_roc_abort_sync(struct mt792x_dev *dev)
371371
{
372372
struct mt792x_phy *phy = &dev->phy;
373373

374+
if (!test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state))
375+
return;
376+
374377
timer_delete_sync(&phy->roc_timer);
375-
cancel_work_sync(&phy->roc_work);
376-
if (test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state))
377-
ieee80211_iterate_interfaces(mt76_hw(dev),
378-
IEEE80211_IFACE_ITER_RESUME_ALL,
379-
mt7921_roc_iter, (void *)phy);
378+
cancel_work(&phy->roc_work);
379+
380+
ieee80211_iterate_interfaces(mt76_hw(dev),
381+
IEEE80211_IFACE_ITER_RESUME_ALL,
382+
mt7921_roc_iter, (void *)phy);
380383
}
381384
EXPORT_SYMBOL_GPL(mt7921_roc_abort_sync);
382385

0 commit comments

Comments
 (0)