summaryrefslogtreecommitdiff
path: root/drivers
AgeCommit message (Collapse)Author
2026-10-07wifi: mt76: mt7925: keep the join ROC until the station is authorizedMark Anthony Agarro
When a non-MLO station associates, mgd_complete_tx() aborts the join ROC as soon as the association succeeds, which is right before the supplicant sends message 2 of the 4-way handshake. With the abort that close to message 2, the adapter acknowledges nothing the AP sends for the next several ms: the AP sends message 3 and its seven retries within about 5 ms, none is acknowledged, and the handshake ends with reason 15 (4WAY_HANDSHAKE_TIMEOUT). Keep the ROC after a successful (re)association on a non-MLD station interface and release it when the station is authorized, on disassociation, or when the station is removed. The ROC timer still ends it if none of that happens. MLD interfaces keep the old behaviour: there the ROC that is active at this point is the MLO ROC set up by mt7925_mac_set_links(), and holding it makes mt7925_set_mlo_roc() fail with -EBUSY in the link activation work, which leaves one link instead of two. Tested by a reporter on an MT7925U (USB) against a FRITZ!Box 5690 Pro on a 6 GHz-only, non-MLO SSID, kernel 7.2.3, from traces and monitor captures taken in separate runs: handshakes first M3 acked abort before M2 unpatched 8 of 84 0 of 83 84 of 84 this patch 30 of 30 31 of 31 0 of 30 With the patch the AP sends message 3 once and the adapter acknowledges it straight away; the ROC is released right after the station is authorized. A 20 ms delay after the abort instead of this change gave 15 of 15, which points at the abort timing and not at the delay. Tested here on an MT7925 and an MT7927 (PCIe), kernel 7.3.0-rc4: on a non-MLO SSID neither build showed the failure (1 stalled handshake in 110 unpatched, none patched), so no effect could be measured there. On an MLO connection the change is inert: 16 of 16 link activations succeeded in two rounds per build, with two active links and the same ROC order as before. Not tested: other APs, other USB parts, MT7927 over USB, MLO connections beyond the check above. Fixes: c948b5da6bbe ("wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips") Reported-by: Mark Junker <fubar-coder@live.de> Closes: https://github.com/morrownr/mt76/issues/106 Tested-by: Mark Junker <fubar-coder@live.de> Signed-off-by: Mark Anthony Agarro <markanthonyagarro@gmail.com> Signed-off-by: Devin Wittmayer <lucid_duck@justthetip.ca> Link: https://patch.msgid.link/20261006031425.20922-1-lucid_duck@justthetip.ca Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7921: keep the join ROC until the station is authorizedMark Anthony Agarro
When an association succeeds mac80211 calls mgd_complete_tx(), and mt7921 aborts the join ROC there. The AP starts the 4-way handshake right away, so the abort lands where message 3 arrives. On an MT7922 this loses message 3 often enough to matter: the supplicant sends message 2 (acked), never receives message 3, and the connection ends with reason 15 (4WAY_HANDSHAKE_TIMEOUT) after about 3.3 s. The mt7925 capture in the linked issue shows the same ordering: abort, message 2 out, then message 3 retried by the AP several times without an answer. Keep the ROC after a successful (re)association on a station interface and release it when the station is authorized, on disassociation, or when the station is removed. The ROC timer still ends it if none of that happens. The state lives in a flag in struct mt792x_vif so that an unrelated ROC, for example a user remain-on-channel, is never aborted by the authorize hook. Tested on an MT7922 (PCIe), kernel 7.3.0-rc4, WPA3-SAE AP, two rounds of 20 disconnect/reconnect cycles per build in the same boot, unpatched and patched in ABAB order: unpatched 34 of 73 association attempts: M1 rx, M2 tx acked, no M3, reason 15 patched 0 of 40 Delaying the abort by 20 ms before it made no difference (8 of 29), and delaying 20 ms after it removed the failures (0 of 20), so what matters is where the abort lands relative to the handshake. The firmware behaviour after the abort is inferred from these outcomes, not observed directly. Not tested: MT7921 and other connac2 parts, USB and SDIO, APs other than the one above, open or WPA2 networks, scheduled scan, suspend and resume. Fixes: 41ac53c899bd ("wifi: mt76: mt7921: introduce chanctx support") Link: https://github.com/morrownr/mt76/issues/106 Signed-off-by: Mark Anthony Agarro <markanthonyagarro@gmail.com> Signed-off-by: Devin Wittmayer <lucid_duck@justthetip.ca> Link: https://patch.msgid.link/20261005203846.239445-1-lucid_duck@justthetip.ca Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7928: makes struct beacon_tlv 4-byte aligned.Anthony Liu
mt76 fails when offloading beacon to MT7928 FW. This is caused by newly added 4-byte alignment check in MT7928 FW and works when beacon_tlv is 4-byte aligned. MT7925 is not affected because it accepts same struct with or without extra padding bytes. Signed-off-by: Anthony Liu <anthony.liu@mediatek.com> Link: https://patch.msgid.link/20261005083904.107527-1-anthony.liu@mediatek.com Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7925: keep MLD membership consistent during link addAndrei Rusu de Castro
mt7925_mac_link_sta_add() sends an ASSOC update for the primary WCID before sending the update for a new secondary WCID. The new link is published in msta->link[] and msta->valid_links only after both commands succeed. Selecting the secondary entry from the subject of each command gives the primary STA_REC_MLD one link and the secondary STA_REC_MLD two links. Enumerating published links alone still omits the pending link from the primary command. Firmware-bound command captures reproduce this n=1/n=2 sequence during a secondary addition. Build each MLD TLV from the station's published links and an explicit pending link. Pass the initialized pending link through both add-time station updates, including the update whose subject is the primary. Keep the primary first, bound entries by the firmware array, and skip links without station and BSS state. Other update callers have no pending link. This leaves msta->link[] publication after successful link setup and preserves the existing add-failure cleanup. The pending pointer is used synchronously to populate the command, not stored in shared state. Fixes: ff643b81bc38 ("wifi: mt76: mt7925: pass mlink and mconf to sta_mld_tlv()") Link: https://lore.kernel.org/linux-wireless/066b30cc-a9e6-4aeb-964d-71551e8ea3ef@posteo.de/ Signed-off-by: Andrei Rusu de Castro <arc@empyreal.works> Tested-by: Devin Wittmayer <lucid_duck@justthetip.ca> Tested-by: Jonas Hort <jonas.hort@posteo.de> Link: https://patch.msgid.link/20261004-mt7925-mld-v2-248bb5e6404f@empyreal.works Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7996: add NET_AIROHA dependencyArnd Bergmann
MT7996E fails to link as build-in when NET_AIROHA=m: WARNING: unmet direct dependencies detected for MT76_NPU Depends on [m]: NETDEVICES [=y] && WLAN [=y] && WLAN_VENDOR_MEDIATEK [=y] && (NET_AIROHA_NPU [=y]=y [=y] || MT76_CORE [=y]=NET_AIROHA_NPU [=y]) && (NET_AIROHA [=m] || !NET_AIROHA [=m]) Selected by [y]: - MT7996_NPU [=y] && NETDEVICES [=y] && WLAN [=y] && WLAN_VENDOR_MEDIATEK [=y] && MT7996E [=y] && (NET_AIROHA_NPU [=y]=y [=y] || MT76_CORE [=y]=NET_AIROHA_NPU [=y]) arm-linux-gnueabi-ld: drivers/net/wireless/mediatek/mt76/npu.o: in function `mt76_npu_init': npu.c:(.text.mt76_npu_init+0x4c): undefined reference to `airoha_ppe_get_dev' arm-linux-gnueabi-ld: npu.c:(.text.mt76_npu_init+0xf8): undefined reference to `airoha_ppe_put_dev' Add another dependency to prevent this configuration, with an explicit special case to allow the NPU to be used while the PPE code is stubbed out with NET_AIROHA=n. Fixes: 377aa17d2aed ("wifi: mt76: mt7996: Add NPU offload support to MT7996 driver") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Link: https://patch.msgid.link/20260928145210.3153783-1-arnd@kernel.org Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7615: cancel reset work during unregisterJiale Yao
The MCU error interrupt handler queues reset_work on the device workqueue. Device removal can reach mt76_unregister_device() while that work is still pending, since the workqueue is not destroyed until mt76_free_device(). If reset_work runs in this window, it operates on an unregistered hw and can requeue mac_work after ieee80211_unregister_hw() has torn the device down. Cancel it before unregistering the device so it cannot outlive the registered hw. Fixes: 61c4fa721968 ("mt76: mt7615: implement hardware reset support") Cc: stable@vger.kernel.org Signed-off-by: Jiale Yao <yaojiale02@163.com> Link: https://patch.msgid.link/20260927101041.957362-1-yaojiale02@163.com Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt76x02: validate RX padding before useJiale Yao
The RX descriptor provides L2 and PN padding lengths that are used to locate the CCMP IV and determine how many bytes to remove from the packet. These lengths are not checked against the received skb length before the IV is read or mt76x02_remove_hdr_pad() is called. Reject frames whose IV does not fit within the skb or whose header padding would extend past the end of the skb. Fixes: 30ce7f4456ae ("mt76: validate rx CCMP PN") Signed-off-by: Jiale Yao <yaojiale02@163.com> Link: https://patch.msgid.link/20260925152754.2323624-1-yaojiale02@163.com Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: move the channel survey when the channel changesDevin Wittmayer
mt7921 and mt7925 report every survey counter against one channel and never mark the one in use. With firmware channel management, both use channel contexts and never call __mt76_set_channel(), so phy->chan_state, phy->chandef and phy->main_chandef keep the first channel of the band. Update them when a context is assigned or changed, after booking the time spent on the old channel. This also makes the legacy rate lookup in mt76_connac2_mac_fill_txs() and mt7925_mac_add_txs_skb() use the band of the current channel. With two channel contexts (multi-channel or MLO), the survey follows the context that was assigned or changed last, since the driver reads the band 0 counters only. Tested on MT7922 over PCIe, MT7921AU and MT7925 over USB. Fixes: 41ac53c899bd ("wifi: mt76: mt7921: introduce chanctx support") Fixes: c948b5da6bbe ("wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips") Cc: stable@vger.kernel.org Reported-by: Chris <hoopyfrood42@gmail.com> Closes: https://lore.kernel.org/linux-wireless/CAHaeJsT8O8Nhq351hFp3NAL8e0iU85N-LBdYZ9nYHFHVy7t_hQ@mail.gmail.com/ Signed-off-by: Devin Wittmayer <lucid_duck@justthetip.ca> Link: https://patch.msgid.link/20261001003501.2425492-1-lucid_duck@justthetip.ca Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7925: cancel mlo_pm_work on the USB stop pathDevin Wittmayer
Every other teardown path cancels this work, PCIe unbind included. USB unbind does not: PCIe has its own unregister hook for it, while USB shares a generic one and the stop callback that would have covered it is replaced in probe. That cancel came in commit 81faf578320d ("wifi: mt76: mt7925: cancel mlo_pm_work on stop"), whose last line says it covers both buses. That's mine and it's a boo-boo. Give the USB path its own stop that cancels the work first. Two-link MLO on a Netgear A9000, work armed then the interface down: stock patched stop ran 3/3 3/3 work still ran 3/3 0/3 Skipping the stop entirely leaves both builds running it, so the zero is the cancel. Fixes: 276a56883257 ("wifi: mt76: mt7925: update the power-saving flow") Cc: stable@vger.kernel.org Signed-off-by: Devin Wittmayer <lucid_duck@justthetip.ca> Link: https://patch.msgid.link/20261003234944.96066-1-lucid_duck@justthetip.ca Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: take rcu_read_lock in the USB/SDIO tx completion pathDevin Wittmayer
The USB and SDIO completion path reads a station pointer that RCU protects, without holding the read lock. Lockdep catches it on the first association: mt76.h:1305 suspicious rcu_dereference_check() usage! no locks held by mt76-usb-status/1254. mt7925_usb_sdio_tx_complete_skb+0x119/0x130 [mt7925_common] mt76_queue_tx_complete+0x27/0x60 [mt76] mt76u_status_worker+0xed/0x1e0 [mt76_usb] mt7925/mac.c:856 suspicious rcu_dereference_check() usage! mt7925_tx_check_aggr.part.0+0xc2/0xe0 [mt7925_common] mt7925_usb_sdio_tx_complete_skb+0xa0/0x130 [mt7925_common] mt7921 does the same, and warns once instead of twice because its aggregation check reads the default link directly. The DMA path makes the same reads but completes from softirq, so it stays quiet. Take the read lock around the lookup and the check. Tested on 7.2-rc5 with lockdep, fresh module load per arm, 4000 packets each and no change to the link: splats before after MT7925 Netgear A9000 2 0 MT7921 Alfa 1 0 mt7921e same kernel 0 0 Fixes: dc66a129adf1 ("wifi: mt76: add a wrapper for wcid access with validation") Fixes: c22769de2509 ("wifi: mt76: mt7925u: use connac3 tx aggr check in tx complete") Cc: stable@vger.kernel.org Signed-off-by: Devin Wittmayer <lucid_duck@justthetip.ca> Link: https://patch.msgid.link/20261003233056.94497-1-lucid_duck@justthetip.ca Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: connac2: fill TXD spe_idx for connac2 fixed-rate framesCharlie-cy Wu
On connac2 chipsets - MT7920, MT7921 and MT7922 - the spe_idx of fixed-rate frames was never programmed, so every management frame - auth and assoc req included - went out 1SS 1T on WF0 instead of 1SS 2T duplicate, giving up ~3dB of array gain during connection setup, which is exactly when the link budget is worst. mt76_connac2_mac_write_txwi() takes the MT_TXD2_FIX_RATE path for any non-data frame, but the block filling MT_TXD7_SPE_IDX was guarded by !is_connac2(), leaving the field at 0. As spe_idx 0 also encodes "WF0" the hardware happily transmitted on a single path. Drop the guard so connac2 fills the index like the other generations do. Do not set MT_TXD6_SPE_ID_IDX along with it: on connac2 that bit points the hardware at the WTBL instead of the TXD, and the WTBL spe_idx is still 0 while connecting, so setting it puts the frames back on WF0. This matches connac3, where SPE_IXD_SELECT_TXD is 0 and SPE_IXD_SELECT_BMC_WTBL is 1, and is the opposite of what the falcon firmware macro name HAL_MAC_TX_DESC_SET_FR_SPE_IDX_SPE_BY_TXD suggests. Guard the duplicate fallback with hweight8() as well: ant_to_spe[] maps a single-antenna mask to 0 too, so without the check a user asking for one antenna would still get spe_idx 24 and duplicate onto both paths. Verified on MT7922: TXD DW7 spe_idx now reads 0x18 and the in-chip sniffer reports spe_idx 0x18 in the TXV of auth and assoc req, where it previously reported 0x0. MT7920 and MT7921 share the same connac2 TXD path and are fixed by the same change. Fixes: 5c81a4f182d9 ("wifi: mt76: connac: use is_connac2() to replace is_mt7921() checks") Signed-off-by: Charlie-cy Wu <Charlie-cy.Wu@mediatek.com> Link: https://patch.msgid.link/20260930083103.1284937-1-jb.tsai@mediatek.com Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: fix wcid teardown ordering in mt76_reset_device()Ryan Leung
mt76_reset_device() tears down each wcid's pktid idr before clearing dev->wcid[i], which is the reverse of the ordering used on the sta removal path. Until the pointer is cleared, a concurrent lookup under status_lock can still find the wcid and access its already destroyed idr. Clear dev->wcid[i] before calling mt76_wcid_cleanup(), reproducing the ordering mac80211 already enforces for normal sta removal (where mt76_sta_pre_rcu_remove() clears dev->wcid[idx] before mt76_wcid_cleanup() runs via the .sta_state callback). Fixes: 065c79df595a ("wifi: mt76: mt7915: fix list corruption after hardware restart") Signed-off-by: Ryan Leung <untilscour@protonmail.com> Link: https://patch.msgid.link/20260821-mt76-wcid-null-before-cleanup-v1-1-0e364d9062d6@protonmail.com Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: fix unlocked wcid check in mt76_tx_status_skb_add()Ryan Leung
mt76_tx_status_skb_add() checks rcu_access_pointer(dev->wcid[wcid->idx]) before taking dev->status_lock, then allocates a pktid afterwards. A concurrent mt76_wcid_cleanup() can run between the check and the lock, letting a stale wcid be re-added to dev->wcid_list after teardown. Worse, the check only tests for a non-NULL slot, so it also passes if a different wcid has since been published at the same idx. Move the check under status_lock, alongside idr_alloc(), and compare identity (rcu_access_pointer(dev->wcid[wcid->idx]) != wcid) instead of just testing for non-NULL, so that a reused index is correctly rejected. Fixes: fcfe1b5e162b ("mt76: fix tx status related use-after-free race on station removal") Signed-off-by: Ryan Leung <untilscour@protonmail.com> Link: https://patch.msgid.link/20260821-mt76-stale-wcid-race-v2-1-8f41ee96fb73@protonmail.com Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7915: publish wcid before MCU add commandsRyan Leung
mt7915_add_interface() enables the BSS/STA in firmware via mt7915_mcu_add_bss_info() and mt7915_mcu_add_sta() before publishing dev->mt76.wcid[idx] with rcu_assign_pointer(). Firmware can start generating tx-status/tx-free events referencing that wcid as soon as it processes those MCU commands, but mt76's rx/tx-free handlers (e.g. mt7915_mac_tx_free()) look up dev->mt76.wcid[idx] to service them, and won't find it published yet. This can lead to memory corruption and kernel crashes shortly after an AP interface is brought up. This ordering was introduced by commit 8e3e7567b8c1 ("mt76: mt7915: add sta_rec with EXTRA_INFO_NEW for the first time only"): mt7915_mcu_add_sta() derived its "newly added" flag from !rcu_access_pointer(dev->mt76.wcid[idx]), so the publish had to happen after that call. Commit 33eb14f10290 ("wifi: mt76: mt7915: use mac80211 .sta_state op") later replaced that flag with a caller-supplied `newly` argument to mt7915_mcu_add_sta(), now simply hardcoded to true, so the ordering is no longer required. Move the rcu_assign_pointer() before the MCU add_bss_info/add_sta calls, so that the wcid is visible to lookups before firmware is told it's live. This makes the ordering symmetric with mt7915_remove_interface(), which keeps the pointer published until after the MCU disable commands have been issued. Closes: https://github.com/openwrt/openwrt/issues/24594 Fixes: 8e3e7567b8c1 ("mt76: mt7915: add sta_rec with EXTRA_INFO_NEW for the first time only") Signed-off-by: Ryan Leung <untilscour@protonmail.com> Link: https://patch.msgid.link/20260821-mt7915-wcid-publish-order-v2-1-acf0b7f32cbd@protonmail.com Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7615: restore DBDC state after ext PHY failureMyeonghun Pak
mt7615_register_ext_phy() limits the primary PHY to DBDC capabilities before allocating and registering the secondary PHY. If allocation, EEPROM override, or PHY registration fails, it returns without restoring the primary PHY capabilities. The EEPROM override failure also leaks the newly allocated ieee80211_hw. Route all failures through common labels that free the secondary hardware when it was allocated and restore the primary PHY capabilities. This issue was identified during our ongoing static-analysis research while reviewing kernel code. Fixes: 0f2173f093b3 ("mt76: mt7615: add support for registering a second wiphy via debugfs") Cc: stable@vger.kernel.org Co-developed-by: Ijae Kim <ae878000@gmail.com> Signed-off-by: Ijae Kim <ae878000@gmail.com> Signed-off-by: Myeonghun Pak <mhun512@gmail.com> Link: https://patch.msgid.link/20260910215441.76683-1-mhun512@gmail.com Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: fix memory leak in USB TX pathEason Lai
When errors occur in mt76u_tx_queue_skb(), the skb is not properly freed, leading to memory leaks. This happens when: - The queue is full - tx_prepare_skb() drops zero-length frames (such as WMM NULL frames) to prevent hardware TX hangs - Buffer setup fails Fix by properly releasing the skb with ieee80211_tx_status_ext() when the queue is full or tx_prepare_skb() fails, and using mt76_tx_complete_skb() when mt76u_tx_setup_buffers() fails (since tx_prepare_skb() has already succeeded and may have allocated resources that need cleanup) Fixes: b40b15e1521f ("mt76: add usb support to mt76 layer") Cc: stable@vger.kernel.org Tested-by: Devin Wittmayer <lucid_duck@justthetip.ca> Closes: https://github.com/morrownr/mt76/issues/83 Signed-off-by: Eason Lai <eason.lai@mediatek.com> Tested-by: Hans Buchheim <hbuchheim@gmail.com> Reported-by: Sergei Melnichenko <sergei.melnichenko@gmail.com> Signed-off-by: Devin Wittmayer <lucid_duck@justthetip.ca> Link: https://patch.msgid.link/20260914021920.32246-3-eason.lai@mediatek.com Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt792x: fix UAF in SDIO TX path when out of memoryEason Lai
Using __skb_pad() instead of skb_pad() in mt76_skb_adjust_pad() to prevent double-free, as the caller handles cleanup. Free the MCU message skb in __mt76x02u_mcu_send_msg() as well, which relied on skb_pad() to release it. Fixes: 808f2767d421 ("wifi: mt76: mt792x: Fix memory leak in SDIO TX path") Cc: stable@vger.kernel.org Closes: https://github.com/morrownr/mt76/issues/83 Co-developed-by: Devin Wittmayer <lucid_duck@justthetip.ca> Signed-off-by: Devin Wittmayer <lucid_duck@justthetip.ca> Signed-off-by: Eason Lai <eason.lai@mediatek.com> Link: https://patch.msgid.link/20260914021920.32246-2-eason.lai@mediatek.com Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7615: do not tear down BSS/STA state for monitor vifsMark Anthony Agarro
Tearing down a monitor interface oopses: BUG: kernel NULL pointer dereference, address: 0000000000000000 RIP: 0010:mt76_connac_mcu_uni_add_bss+0x144/0x370 [mt76_connac_lib] Call Trace: mt7615_remove_interface+0x6a/0x200 [mt7615_common] drv_remove_interface+0x60/0x140 [mac80211] ieee80211_del_virtual_monitor+0x8f/0xc0 [mac80211] ieee80211_do_open+0x550/0x7d0 [mac80211] ieee80211_open+0xaa/0xb0 [mac80211] __dev_open+0x11b/0x280 mt7615_remove_interface() tears down BSS and STA state for every vif type. On MT7663 with offload firmware that reaches mt76_connac_mcu_uni_add_bss(), which has no monitor case in its iftype switch. It takes WARN_ON(1), then copies ETH_ALEN from vif->bss_conf.bssid, which is NULL for a monitor vif. mt76_connac_mcu_bss_basic_tlv() in the same file handles this. It has an NL80211_IFTYPE_MONITOR case and it copies phy->macaddr in place of the bssid. The uni variant has neither. There is nothing to tear down. mt7615_add_interface() only calls mt7615_mcu_add_dev_info(). The BSS and STA state comes from beacon enable in mt7615_bss_info_changed(), from mt7615_set_key() and from mt7615_mac_sta_add(), so a monitor vif never has any. Reported on mt7615e going from monitor back to managed, and on mt7663u on an "ip link set down", both through ieee80211_del_virtual_monitor(). Fixes: d9852ab2f362 ("mt76: mt7615: keep mcu_add_bss_info enabled till interface removal") Cc: stable@vger.kernel.org Reported-by: Orly Orge <orlyorge2004@gmail.com> Closes: https://lore.kernel.org/linux-wireless/CANj5C4mTOHs6riyWee=dFdkE5p=714J8xs-x3hq3ewQ+r6O_Nw@mail.gmail.com/ Reported-by: Inanix <contact@inanix.fr> Closes: https://github.com/morrownr/mt76/issues/79 Tested-by: Inanix <contact@inanix.fr> Signed-off-by: Mark Anthony Agarro <markanthonyagarro@gmail.com> Signed-off-by: Devin Wittmayer <lucid_duck@justthetip.ca> Link: https://patch.msgid.link/20260813152059.15747-1-lucid_duck@justthetip.ca Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7996: unlink TWT flow if the MCU rejects the agreementZhao Li
mt7996_mac_add_twt_setup() links a new flow into dev->twt_list before asking the MCU to add the agreement, but exits without unlinking the flow if the request fails. The flow-ID and table masks are only committed after MCU success, so the still-linked flow is invisible to the mask-gated teardown paths. If the station retries the setup, the same slot is cleared and its embedded list node reinitialized while it is still linked, corrupting dev->twt_list. If the station disassociates instead, teardown skips the flow and station storage can be freed while the node remains linked. A later scheduling or debugfs twt_stats walk can then dereference the freed flow, resulting in a use-after-free. Unlink the flow when the MCU rejects the agreement. This restores the list to its pre-request state while leaving the unchanged mask and agreement accounting untouched. Fixes: 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices") Cc: stable@vger.kernel.org Link: https://lore.kernel.org/all/20260729173632.14387-3-enderaoelyther@gmail.com/ Assisted-by: Codex:gpt-5.6-sol Assisted-by: Kimi:K3 Signed-off-by: Zhao Li <enderaoelyther@gmail.com> Link: https://patch.msgid.link/20260825112620.97568-1-enderaoelyther@gmail.com Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7921: honour FIF_FCSFAIL instead of hardcoding drop_errDevin Wittmayer
When a monitor interface asks to see frames that failed their checksum, mac80211 passes the request down to the driver. mt7921 works out the answer, sends it to the firmware as a receive filter, and then configures the sniffer with a hardcoded byte telling it to drop those frames anyway. The answer is used once and never kept, so the sniffer never gets to see it. That matters to anyone using monitor mode to judge a link honestly, which is most of the reason to be in monitor mode at all. Mark Anthony Agarro posted the same change for mt7925: keep what mac80211 asked for on the phy, and read it back when the sniffer is configured. This does that for mt7921, and applies on top of it, since that patch is what adds the field. https://lore.kernel.org/linux-wireless/20260826091757.469953-1-markanthonyagarro@gmail.com/ The stored value is read in one place only, configuring the sniffer, which has a single caller, and that call sits inside a branch reached only by a monitor interface. Nothing else changes. Measured on an MT7922 with a read-only probe on the command as the driver sends it, so these are the driver's own bytes rather than an inference from what came back: request arm drop_err none stock 1 1 1 1 none patched 1 1 1 1 fcsfail stock 1 1 fcsfail patched 0 0 Stock sends the drop byte whether or not anyone asked for it. Patched sends it only when nobody did. Withdrawing the request and making it again inside one driver load moves the byte back and forth, 0 then 1 then 0 across three changes, so nothing sticks once set. If it does appear to stick when trying this against an MT7927, that is mac80211 rather than the driver. It raises the filter count unconditionally when a monitor comes up, but skips lowering it again for drivers that set NO_VIRTUAL_MONITOR, and that is the only chip in this family which does. Fixes: 914189af23b8 ("wifi: mt76: mt7921: fix channel switch fail in monitor mode") Signed-off-by: Devin Wittmayer <lucid_duck@justthetip.ca> Link: https://patch.msgid.link/20260826231029.39632-1-lucid_duck@justthetip.ca Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7925: honour mac80211's FIF_FCSFAIL instead of hardcoding drop_errMark Anthony Agarro
mt7925_mcu_config_sniffer() hardcodes drop_err = 1, ignoring what mac80211 actually requested via configure_filter(). FIF_FCSFAIL is computed there but discarded instead of persisted. Persist the FCSFAIL bit on the phy in mt7925_configure_filter() and read it back in mt7925_mcu_config_sniffer() to derive drop_err, so the firmware sniffer only passes through unfiltered/marginal frames when a monitor listener actually requested them. mt7925_mcu_config_sniffer() is only reached from mt7925_change_chanctx(), which is itself only exercised on a monitor-mode chanctx, so this stays scoped to monitor mode. Fixes: c948b5da6bbe ("wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips") Tested-by: Devin Wittmayer <lucid_duck@justthetip.ca> Signed-off-by: Mark Anthony Agarro <markanthonyagarro@gmail.com> Link: https://patch.msgid.link/20260826091757.469953-1-markanthonyagarro@gmail.com Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt76x02: validate TX-status rate index before mac80211 handoffMark Anthony Agarro
mt76x02_mac_process_tx_rate() extracts the rate index straight from the hardware's raw TX-status word with no bounds check for the HT/HT_GF/VHT cases, and mt76x02_mac_fill_tx_status() ignores its return value. A stale or corrupt hardware index reaches mac80211's minstrel_ht rate control, whose per-group rate array is a fixed 10 entries (MCS_GROUP_RATES), causing an out-of-bounds write. Validate the index in mt76x02_mac_process_tx_rate() (HT: 0-31, VHT: MCS nibble 0-9) and have mt76x02_mac_fill_tx_status() bail out cleanly on failure instead of passing an invalid index through. Fixes: 7c1f88812690 ("mt76: unify send_tx_status and related helpers") Cc: stable@vger.kernel.org Tested-by: Devin Wittmayer <lucid_duck@justthetip.ca> Signed-off-by: Mark Anthony Agarro <markanthonyagarro@gmail.com> Link: https://patch.msgid.link/20260826092755.480190-1-markanthonyagarro@gmail.com Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7925: fix the lock inversion in suspend and resumeDevin Wittmayer
Same as the previous patch, other driver. Fixes: c948b5da6bbe ("wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips") Signed-off-by: Devin Wittmayer <lucid_duck@justthetip.ca> Link: https://patch.msgid.link/20260830064201.92285-3-lucid_duck@justthetip.ca Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7921: fix the lock inversion in suspend and resumeDevin Wittmayer
Same inversion as the config path, same one word fix, missed the first time. Both are called with the wiphy mutex held, so the walk can rely on that instead of taking the list mutex. No new splat: same class pair as the accepted fix, and lockdep reports a pair once per boot. Fixes: ffa1bf97425b ("mt76: mt7921: introduce PM support") Link: https://patch.msgid.link/20260810045338.118923-2-lucid_duck@justthetip.ca Signed-off-by: Devin Wittmayer <lucid_duck@justthetip.ca> Link: https://patch.msgid.link/20260830064201.92285-2-lucid_duck@justthetip.ca Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7925: restore the reset state when fw_pmctrl failsFelix Fietkau
mt7925e_mac_reset() returns directly when mt792xe_mcu_fw_pmctrl() fails, leaving MT76_RESET set and the TX worker parked. Every other error path jumps to out, which clears both. mt7925_mac_reset_work() clears neither, so once every reset attempt fails there, TX stays blocked until another reset succeeds. Jump to out instead. Fixes: c948b5da6bbe ("wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips") Link: https://patch.msgid.link/20260827162115.1449757-1-nbd@nbd.name Acked-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7925: check drv_pmctrl return in the PCIe reset pathDevin Wittmayer
mt7925e_mac_reset() ignores the return value of mt792xe_mcu_drv_pmctrl(), unlike the two pmctrl calls later in the same function. When the driver-own handshake fails, __mt792xe_mcu_drv_pmctrl() returns -EIO without reinitialising WPDMA or clearing MT76_STATE_PM, and the reset carries on: it writes the interrupt enable registers, cycles NAPI, resets WPDMA and calls mt7925_run_firmware() on a chip the driver does not own. Return the error instead. The call is the first statement in the function, before MT76_RESET is set and before the TX worker and NAPI are disabled, so nothing needs unwinding. Fixes: c948b5da6bbe ("wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips") Signed-off-by: Devin Wittmayer <lucid_duck@justthetip.ca> Link: https://patch.msgid.link/20260809205559.32116-1-lucid_duck@justthetip.ca Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7921: check drv_pmctrl return in the PCIe reset pathDevin Wittmayer
mt7921e_mac_reset() ignores the return value of mt792xe_mcu_drv_pmctrl(). When the driver-own handshake fails, __mt792xe_mcu_drv_pmctrl() returns -EIO without reinitialising WPDMA or clearing MT76_STATE_PM, and the reset carries on: it writes the interrupt enable registers, cycles NAPI, resets WPDMA and downloads firmware to a chip the driver does not own. Return the error instead. The call is the first statement in the function, before any teardown, so nothing needs unwinding. Reported-by: moosager <moosager90@gmail.com> Link: https://lore.kernel.org/linux-wireless/anG46qbvCqCHGF-f@fedora.fritz.box/ Fixes: dfc7743de1eb ("mt76: mt7921: refactor mcu.c to be bus independent") Signed-off-by: Devin Wittmayer <lucid_duck@justthetip.ca> Tested-by: moosager <moosager90@gmail.com> Link: https://patch.msgid.link/20260809012309.43657-1-lucid_duck@justthetip.ca Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7925: fix lock inversion between dev->mutex and iflist_mtxDevin Wittmayer
mt7925_config() has the same inversion as mt7921_config(): it holds dev->mutex across ieee80211_iterate_active_interfaces(), which takes local->iflist_mtx, while mac80211 calls drv_unassign_vif_chanctx() with iflist_mtx already held. .config is only reached through drv_config(), which asserts the wiphy mutex, so use ieee80211_iterate_active_interfaces_mtx() here too. Fixes: c948b5da6bbe ("wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips") Signed-off-by: Devin Wittmayer <lucid_duck@justthetip.ca> Link: https://patch.msgid.link/20260810045338.118923-3-lucid_duck@justthetip.ca Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7921: fix lock inversion between dev->mutex and iflist_mtxDevin Wittmayer
mt7921_config() holds dev->mutex across ieee80211_iterate_active_interfaces(), which takes local->iflist_mtx. mac80211 uses the opposite order: ieee80211_del_virtual_monitor() holds iflist_mtx while calling drv_unassign_vif_chanctx(), and mt792x_unassign_vif_chanctx() takes dev->mutex. Deleting a monitor interface that has a channel assigned reaches the second order and lockdep reports the cycle. The driver side of it: -> #1 (&local->iflist_mtx){+.+.}-{4:4}: __mutex_lock+0xda/0x1070 ieee80211_iterate_interfaces+0x34/0x70 [mac80211] mt7921_config+0xb8/0xe0 [mt7921_common] drv_config+0x63/0x1d0 [mac80211] .config is only reached through drv_config(), which asserts the wiphy mutex, so ieee80211_iterate_active_interfaces_mtx() can be used. It walks the same list under the wiphy mutex and never takes iflist_mtx, which drops the driver's dev->mutex -> iflist_mtx edge. Fixes: cbaa0a404f8d ("mt76: mt7921: fix up the monitor mode") Link: https://lore.kernel.org/linux-wireless/20260730053916.109426-1-lucid_duck@justthetip.ca/ Signed-off-by: Devin Wittmayer <lucid_duck@justthetip.ca> Link: https://patch.msgid.link/20260810045338.118923-2-lucid_duck@justthetip.ca Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7925: fix HT/VHT caps and rates for NAN NDP peersJacobs Wu
NAN NDP peers were added with bare link_sta caps: no HT cap or QoS flag (so no BA/A-MPDU), no VHT cap / bandwidth / rx_nss, a data BSS phy mode that still read legacy when the firmware built the peer's rate table, and caps filtered down by the currently committed schedule. Push the NAN_DATA BSS phymode before sta_update, force the HT cap and QoS flag, seed VHT80 / bandwidth / rx_nss=2 from the BSS RLM, fix the NDP HT/VHT rate selection and stop filtering the link_sta caps by the schedule, so rate control always sees the peer's real capabilities. Bench (MT7925<->MT7925 NDP, 5 GHz ch149): 866.7M VHT80 MCS9 NSS2 link rate, UDP ~290 Mbit/s. Fixes: 0f3605e4f8de ("wifi: mt76: mt7925: wire up NAN operations") Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Jacobs Wu <jacobs.wu@mediatek.com> Link: https://patch.msgid.link/20260824195227.12589-16-sean.wang@kernel.org Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7925: support deferred NAN schedule update and cluster eventsJacobs Wu
Send the is_deferred flag in the availability control TLV so FW applies a deferred schedule change at the next DW boundary, and report the NAN_UNI_EVENT_ID_SCHED_UPDATE_DONE and STARTED_CLUSTER events to mac80211 via ieee80211_nan_sched_update_done() and ieee80211_nan_cluster_joined(). Both events arrive on the BH-disabled MCU RX path, where notifying mac80211 inline is wrong: ieee80211_nan_sched_update_done() needs the wiphy mutex and may sleep, and ieee80211_nan_cluster_joined() would fire during NAN_START before mac80211 sets sdata->u.nan.started and before the supplicant subscribes to NL80211_MCGRP_NAN, so the self-anchor cluster-join is lost and a solo anchor master can never publish a service. Deliver both events from a shared nan_deferred_work selected by a pending bitmap instead. The bitmap spinlock is taken with spin_lock_bh() on the RX side, the work re-checks nan_vif under the wiphy mutex, and the stop path clears the bitmap. STARTED_CLUSTER signals new_cluster=true, and JOINED_CLUSTER is corrected to new_cluster=false. Fixes: a5487a682406 ("wifi: mt76: mt7925: add NAN MCU helpers") Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Co-developed-by: Stella Liu <yu-ching.liu@mediatek.com> Signed-off-by: Stella Liu <yu-ching.liu@mediatek.com> Signed-off-by: Jacobs Wu <jacobs.wu@mediatek.com> Link: https://patch.msgid.link/20260824195227.12589-15-sean.wang@kernel.org Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7925: configure NAN PHY setting on enableStella Liu
Implement NAN_UNI_CMD_UPDATE_PHY_SETTING (tag=18) to configure the BSS-level PHY parameters that the FW NAN scheduler uses when it switches channels. The command carries separate 2G and 5G PHY settings, each with its own phy type, rate sets and protection modes. Fixes: 0f3605e4f8de ("wifi: mt76: mt7925: wire up NAN operations") Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Stella Liu <yu-ching.liu@mediatek.com> Link: https://patch.msgid.link/20260824195227.12589-14-sean.wang@kernel.org Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7925: add ULW event handling and peer ULW updateStella Liu
Forward NAN Unaligned Window attributes between FW and mac80211: report ULW updates from FW via cfg80211_nan_ulw_update() and push peer ULW attributes to FW with NAN_UNI_CMD_UPDATE_ULW. Fixes: 0f3605e4f8de ("wifi: mt76: mt7925: wire up NAN operations") Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Stella Liu <yu-ching.liu@mediatek.com> Link: https://patch.msgid.link/20260824195227.12589-13-sean.wang@kernel.org Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7925: clear CRB before deactivating NAN peer recordStella Liu
Send a zero avail_map CRB TLV before the peer record deactivation command. This ensures FW clears the committed schedule slots for the departing peer, preventing stale CRB entries from affecting subsequent NDP connections. Fixes: a5487a682406 ("wifi: mt76: mt7925: add NAN MCU helpers") Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Stella Liu <yu-ching.liu@mediatek.com> Link: https://patch.msgid.link/20260824195227.12589-12-sean.wang@kernel.org Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7925: fill all DW intervals in NAN avail_mapStella Liu
Fill avail_map for all DW intervals instead of only DW index 0. FW requires the bitmap to be set across all 16 DW intervals for correct NAN scheduling. Without this, NDP ping latency is extremely high (~200ms) because FW only schedules data in the first DW interval. Also set ch_type = 1 for new channel entries to indicate channel-based (non-band) availability. Fixes: a5487a682406 ("wifi: mt76: mt7925: add NAN MCU helpers") Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Stella Liu <yu-ching.liu@mediatek.com> Link: https://patch.msgid.link/20260824195227.12589-11-sean.wang@kernel.org Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7925: replace NAN DW end event with DW startStella Liu
Handle the NAN DW start event instead of the DW end event for DW notification. Queuing NDP action frames at the beginning of the DW window, rather than after it ends, improves NDP handshake reliability. Fixes: a5487a682406 ("wifi: mt76: mt7925: add NAN MCU helpers") Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Stella Liu <yu-ching.liu@mediatek.com> Link: https://patch.msgid.link/20260824195227.12589-10-sean.wang@kernel.org Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7925: share TLV setup for NAN enable commandStella Liu
Refactor mt7925_nan_enable() to build the MCU command from separate TLVs via skb instead of inline fields in the enable request struct. The cluster ID, DW interval, discovery beacon interval and RSSI threshold settings are now shared with mt7925_nan_change_configure() through the common TLV helpers, avoiding duplicated setup code. Fixes: a5487a682406 ("wifi: mt76: mt7925: add NAN MCU helpers") Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Stella Liu <yu-ching.liu@mediatek.com> Link: https://patch.msgid.link/20260824195227.12589-9-sean.wang@kernel.org Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7925: use OFDM-only PHY mode for NAN STA recordsStella Liu
NAN operates with OFDM and does not support CCK, so the phy, rate control and BSS rate TLVs must not fall back to 2.4 GHz. Borrow the 5 GHz band lookup to keep the STA records OFDM-only. Fixes: 9824fb4edbf3 ("wifi: mt76: mt7925: add NAN MCU handling") Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Stella Liu <yu-ching.liu@mediatek.com> Link: https://patch.msgid.link/20260824195227.12589-8-sean.wang@kernel.org Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7925: drop deferred NAN local schedule update handlingStella Liu
The deferred NAN local schedule update path in mt7925_nan_local_sched_changed() is removed for now; it will be implemented separately. Drop the now set-but-unused ret variable along with it. Fixes: 0f3605e4f8de ("wifi: mt76: mt7925: wire up NAN operations") Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Stella Liu <yu-ching.liu@mediatek.com> Link: https://patch.msgid.link/20260824195227.12589-7-sean.wang@kernel.org Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7925: drop unused NAN 2.4/5 GHz support configStella Liu
The config_support_5g/support_5g_val and config_2dot4g_support/ support_2dot4g_val fields in the NAN enable request are not used by the firmware, so stop setting them and drop mt7925_nan_set_2g_support(). Fixes: 0f3605e4f8de ("wifi: mt76: mt7925: wire up NAN operations") Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Stella Liu <yu-ching.liu@mediatek.com> Link: https://patch.msgid.link/20260824195227.12589-6-sean.wang@kernel.org Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7925: report only 2.4 GHz NAN supported bandStella Liu
The firmware only checks the 2.4 GHz bit of the local device capability supported_bands field, so set it directly and drop the unused helper. Fixes: 0f3605e4f8de ("wifi: mt76: mt7925: wire up NAN operations") Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Stella Liu <yu-ching.liu@mediatek.com> Link: https://patch.msgid.link/20260824195227.12589-5-sean.wang@kernel.org Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7925: fix NAN committed CRB timeline layoutStella Liu
The committed CRB timeline carried a local_map_id byte that does not exist in the firmware NAN_SCHEDULE_TIMELINE_T layout (map id plus 3 reserved bytes), shifting the availability bitmap. Drop it and match the firmware structure. The common-slot check is also dropped as redundant: mac80211 already tracks common slots, so avail_map is built directly from the peer schedule. Fixes: 0f3605e4f8de ("wifi: mt76: mt7925: wire up NAN operations") Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Stella Liu <yu-ching.liu@mediatek.com> Link: https://patch.msgid.link/20260824195227.12589-4-sean.wang@kernel.org Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7925: fix NAN start failureStella Liu
mt7925_start_nan() called mt7925_nan_set_nmi_addr(), which makes NAN start fail. The NMI address is not managed here, so drop the call. Also track dev->nan_vif only in add/remove_interface and fold the single BSS rollback into an inline error check. Fixes: 0f3605e4f8de ("wifi: mt76: mt7925: wire up NAN operations") Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Stella Liu <yu-ching.liu@mediatek.com> Link: https://patch.msgid.link/20260824195227.12589-3-sean.wang@kernel.org Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7925: fix NAN NDP STA record role indexStella Liu
The NDP STA record role_idx must carry the NAN BSS band0 index rather than the mac80211 BSS index, otherwise the firmware maps the NDP peer to the wrong role. Use the fixed NAN_BSS_INDEX_BAND0 value. While at it, drop the inline peer-schedule setup in mt792x_nan_map_sta_rec(): the peer schedule is already driven by the upper layer through the peer_sched_changed callback (mt792x_nan_set_peer_schedule()), so the redundant call and the now-unused local variables are removed. Fixes: 0f3605e4f8de ("wifi: mt76: mt7925: wire up NAN operations") Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Stella Liu <yu-ching.liu@mediatek.com> Link: https://patch.msgid.link/20260824195227.12589-2-sean.wang@kernel.org Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7996: bound RRO session id before indexing addr_elem[]Felix Fietkau
seq_id from the WED RRO indication is a 12-bit field (0-4095), but only values up to MT7996_RRO_MAX_SESSION map into wed_rro.addr_elem[], which has MT7996_RRO_ADDR_ELEM_LEN (128) entries. A larger session id computes an out-of-bounds element index that is then read and, on a signature mismatch, written. Reject an out-of-range session id. Fixes: a09d2f9d69af ("wifi: mt76: Convert mt76_wed_rro_ind to LE") Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7915: guard firmware memory dump write on disabled memdumpFelix Fietkau
mt7915_coredump_build()/mt7996_coredump_build() wrote dump_mem->len unconditionally, but the allocation only reserves room for the memory dump header when coredump_memdump is enabled and memdump_buf_len is non-zero. In the default configuration the allocation ends right after the fixed header, so the write landed one struct past the buffer. Only populate the memory-dump section when it was actually allocated. Fixes: 4dbcb9125cc3 ("wifi: mt76: mt7915: enable coredump support") Fixes: 878161d5d4a4 ("wifi: mt76: mt7996: enable coredump support") Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7915: unregister thermal cooling device on hwmon failureFelix Fietkau
mt7915_thermal_init() registered the thermal cooling device and its sysfs link, then returned the hwmon registration error without undoing them. The cooling device (not devm-managed) and the link then leaked, and its callbacks referenced the freed phy. Unregister the cooling device before returning the error. Fixes: 0ae3ff568451 ("mt76: mt7915: fix hwmon temp sensor mem use-after-free") Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7996: validate firmware event lengths before parsingFelix Fietkau
Two unsolicited event handlers trusted firmware-provided lengths: mt7996_mcu_rx_all_sta_info_event() looped over res->sta_num without checking it against skb->len, reading the flex array out of bounds; and mt7996_mcu_rx_log_message() could compute a negative or oversized length from tlv->len and feed it to %.*s and the debugfs log path. Bound both against the actual skb length. Fixes: adde3eed4a75 ("wifi: mt76: mt7996: Add mcu commands for getting sta tx statistic") Fixes: 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices") Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: mt7915: check default EEPROM firmware size before copyingFelix Fietkau
mt7915_eeprom_load_default() copied mt7915_eeprom_size() bytes from the firmware blob after only checking that it was non-NULL. A truncated default bin caused an out-of-bounds read past the firmware buffer into the EEPROM image. Reject a blob smaller than the EEPROM size. Fixes: beed8bea8d74 ("mt76: mt7915: add mt7916 calibrated data support") Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-07wifi: mt76: account non-AQL frames per peer rather than per linkFelix Fietkau
The driver increments wcid->non_aql_packets when a frame goes to the hardware queue. The completion path decrements the counter again. For an MLO peer, the hardware reports the completion on the link that it used for the transmission. This link can differ from the link that the driver queued the frame on. In that case, the increment and the decrement go to different link wcids, and the count drifts upwards until it blocks the station. Keep the count on the wcid of the primary link, like the other peer-wide state. Fixes: 86c051f2c418 ("wifi: mt76: mt7925: enabling MLO when the firmware supports it") Link: https://patch.msgid.link/20260818125825.395538-5-nbd@nbd.name Signed-off-by: Felix Fietkau <nbd@nbd.name>