From: Ajrat Makhmutov <rauty@altlinux.org>
To: stable@vger.kernel.org
Cc: 'Sasha Levin ' <sashal@kernel.org>,
Sean Wang <sean.wang@mediatek.com>,
Quan Zhou <quan.zhou@mediatek.com>, Felix Fietkau <nbd@nbd.name>
Subject: [PATCH 3/3] wifi: mt76: mt7921: fix potential deadlock in mt7921_roc_abort_sync
Date: Wed, 17 Jun 2026 15:57:14 +0300 [thread overview]
Message-ID: <20260617125714.1663242-3-rauty@altlinux.org> (raw)
In-Reply-To: <20260617125714.1663242-1-rauty@altlinux.org>
From: Sean Wang <sean.wang@mediatek.com>
commit d5059e52fd8bc624ec4255c9fa01a266513d126b upstream.
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: 352d966126e6 ("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>
(cherry picked from commit d5059e52fd8bc624ec4255c9fa01a266513d126b)
[ALT: keep del_timer_sync() instead of timer_delete_sync() — the
timer API rename is not present in 6.12.y. ]
---
drivers/net/wireless/mediatek/mt76/mt7921/main.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
index f2fffca868b51..99561094640f1 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
@@ -365,12 +365,15 @@ void mt7921_roc_abort_sync(struct mt792x_dev *dev)
{
struct mt792x_phy *phy = &dev->phy;
+ if (!test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state))
+ return;
+
del_timer_sync(&phy->roc_timer);
- cancel_work_sync(&phy->roc_work);
- if (test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state))
- ieee80211_iterate_interfaces(mt76_hw(dev),
- IEEE80211_IFACE_ITER_RESUME_ALL,
- mt7921_roc_iter, (void *)phy);
+ cancel_work(&phy->roc_work);
+
+ ieee80211_iterate_interfaces(mt76_hw(dev),
+ IEEE80211_IFACE_ITER_RESUME_ALL,
+ mt7921_roc_iter, (void *)phy);
}
EXPORT_SYMBOL_GPL(mt7921_roc_abort_sync);
--
2.50.1
next prev parent reply other threads:[~2026-06-17 12:57 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-10 8:09 [stable request] mt7921e: backport two mt76 fixes to 6.12.y Ajrat Makhmutov
2026-06-11 0:45 ` Sasha Levin
2026-06-11 10:38 ` Ajrat Makhmutov
2026-06-16 13:21 ` Ajrat Makhmutov
2026-06-19 4:06 ` Sasha Levin
2026-06-17 12:57 ` [PATCH 1/3] wifi: mt76: mt7921: avoid undesired changes of the preset regulatory domain Ajrat Makhmutov
2026-06-17 12:57 ` [PATCH 2/3] wifi: mt76: mt7921: fix a potential scan no APs Ajrat Makhmutov
2026-06-17 12:57 ` Ajrat Makhmutov [this message]
2026-06-17 13:08 ` [PATCH v2 1/3] wifi: mt76: mt7921: avoid undesired changes of the preset regulatory domain Ajrat Makhmutov
2026-06-17 13:08 ` [PATCH v2 2/3] wifi: mt76: mt7921: fix a potential scan no APs Ajrat Makhmutov
2026-06-17 13:08 ` [PATCH v2 3/3] wifi: mt76: mt7921: fix potential deadlock in mt7921_roc_abort_sync Ajrat Makhmutov
2026-06-18 8:14 ` [PATCH 6.12.y v3 0/3] mt7921e: backport three mt76 fixes to 6.12.y Ajrat Makhmutov
2026-06-18 8:14 ` [PATCH 6.12.y v3 1/3] wifi: mt76: mt7921: avoid undesired changes of the preset regulatory domain Ajrat Makhmutov
2026-06-18 8:14 ` [PATCH 6.12.y v3 2/3] wifi: mt76: mt7921: fix a potential scan no APs Ajrat Makhmutov
2026-06-18 8:14 ` [PATCH 6.12.y v3 3/3] wifi: mt76: mt7921: fix potential deadlock in mt7921_roc_abort_sync Ajrat Makhmutov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260617125714.1663242-3-rauty@altlinux.org \
--to=rauty@altlinux.org \
--cc=nbd@nbd.name \
--cc=quan.zhou@mediatek.com \
--cc=sashal@kernel.org \
--cc=sean.wang@mediatek.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.