Linux wireless drivers development
 help / color / mirror / Atom feed
From: Felix Fietkau <nbd@nbd.name>
To: linux-wireless@vger.kernel.org
Subject: [PATCH mt76-next 08/17] wifi: mt76: mt7925: take the link conf of a removed link from old[]
Date: Sat, 21 Nov 2026 13:09:17 +0100	[thread overview]
Message-ID: <20261121120926.3603979-8-nbd@nbd.name> (raw)
In-Reply-To: <20261121120926.3603979-1-nbd@nbd.name>

mt7925_change_vif_links() deactivates a removed link through
mt792x_mac_link_bss_remove(), which looks up the link conf in
vif->link_conf[]. ieee80211_vif_update_links() clears that entry before
it calls the driver. If an AP MLD removes a non-default link while
another link stays, the lookup returns NULL, and
mt76_connac_mcu_uni_add_dev() dereferences it. When a non-AP MLD
disassociates, mac80211 removes all links, so the DEV_INFO deactivation
of a non-default link carries the MLD address of vif->bss_conf.

Take the link conf of a removed link from old[], as the
.change_vif_links text in include/net/mac80211.h describes: "The @old
array contains pointers to the old bss_conf structures that were
already removed, in case they're needed." The DEV_INFO deactivation
then carries the link address of its activation. Whether the firmware
reads that address at a deactivation is not known.

The NULL dereference is currently not reachable, because
mt7925_change_vif_links() fails the second ADD_LINK of an AP MLD. Found
by inspection.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 .../net/wireless/mediatek/mt76/mt7925/main.c  | 15 ++++++-----
 drivers/net/wireless/mediatek/mt76/mt792x.h   |  4 +++
 .../net/wireless/mediatek/mt76/mt792x_core.c  | 25 +++++++++++++------
 3 files changed, 30 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index ec4f3db23c07..27a622beb147 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -2550,14 +2550,15 @@ static void mt7925_link_info_changed(struct ieee80211_hw *hw,
 
 static void
 mt7925_vif_link_remove(struct mt792x_dev *dev, struct mt792x_vif *mvif,
-		       unsigned int link_id, struct mt792x_bss_conf *mconf,
+		       unsigned int link_id, struct ieee80211_bss_conf *link_conf,
+		       struct mt792x_bss_conf *mconf,
 		       struct mt792x_link_sta *mlink, bool bss_remove)
 {
 	rcu_assign_pointer(mvif->link_conf[link_id], NULL);
 	rcu_assign_pointer(mvif->sta.link[link_id], NULL);
 
 	if (bss_remove)
-		mt792x_mac_link_bss_remove(dev, mconf, mlink);
+		__mt792x_mac_link_bss_remove(dev, link_conf, mconf, mlink);
 
 	if (mconf != &mvif->bss_conf) {
 		mt7925_p2p_bmc_remove(dev, mconf);
@@ -2596,8 +2597,8 @@ mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 		if (!mconf || !mlink)
 			continue;
 
-		mt7925_vif_link_remove(dev, mvif, link_id, mconf, mlink,
-				       mconf != &mvif->bss_conf);
+		mt7925_vif_link_remove(dev, mvif, link_id, old[link_id], mconf,
+				       mlink, mconf != &mvif->bss_conf);
 	}
 
 	for_each_set_bit(link_id, &add, IEEE80211_MLD_MAX_NUM_LINKS) {
@@ -2671,8 +2672,10 @@ mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 
 free:
 	for_each_set_bit(link_id, &add, IEEE80211_MLD_MAX_NUM_LINKS)
-		mt7925_vif_link_remove(dev, mvif, link_id, mconfs[link_id],
-				       mlinks[link_id], added & BIT(link_id));
+		mt7925_vif_link_remove(dev, mvif, link_id,
+				       mt792x_vif_to_bss_conf(vif, link_id),
+				       mconfs[link_id], mlinks[link_id],
+				       added & BIT(link_id));
 	goto out;
 
 free_unpublished:
diff --git a/drivers/net/wireless/mediatek/mt76/mt792x.h b/drivers/net/wireless/mediatek/mt76/mt792x.h
index 07c5e67db8cd..260abdc978f8 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x.h
+++ b/drivers/net/wireless/mediatek/mt76/mt792x.h
@@ -661,6 +661,10 @@ mt792x_get_mac80211_ops(struct device *dev,
 int mt792x_init_wcid(struct mt792x_dev *dev);
 int mt792x_mcu_drv_pmctrl(struct mt792x_dev *dev);
 int mt792x_mcu_fw_pmctrl(struct mt792x_dev *dev);
+void __mt792x_mac_link_bss_remove(struct mt792x_dev *dev,
+				  struct ieee80211_bss_conf *link_conf,
+				  struct mt792x_bss_conf *mconf,
+				  struct mt792x_link_sta *mlink);
 void mt792x_mac_link_bss_remove(struct mt792x_dev *dev,
 				struct mt792x_bss_conf *mconf,
 				struct mt792x_link_sta *mlink);
diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_core.c b/drivers/net/wireless/mediatek/mt76/mt792x_core.c
index 5babfc00dee1..6a9c0e92cd1a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x_core.c
+++ b/drivers/net/wireless/mediatek/mt76/mt792x_core.c
@@ -281,17 +281,13 @@ void mt792x_stop(struct ieee80211_hw *hw, bool suspend)
 }
 EXPORT_SYMBOL_GPL(mt792x_stop);
 
-void mt792x_mac_link_bss_remove(struct mt792x_dev *dev,
-				struct mt792x_bss_conf *mconf,
-				struct mt792x_link_sta *mlink)
+void __mt792x_mac_link_bss_remove(struct mt792x_dev *dev,
+				  struct ieee80211_bss_conf *link_conf,
+				  struct mt792x_bss_conf *mconf,
+				  struct mt792x_link_sta *mlink)
 {
-	struct ieee80211_vif *vif = container_of((void *)mconf->vif,
-						 struct ieee80211_vif, drv_priv);
-	struct ieee80211_bss_conf *link_conf;
 	int idx = mlink->wcid.idx;
 
-	link_conf = mt792x_vif_to_bss_conf(vif, mconf->link_id);
-
 	mt76_connac_free_pending_tx_skbs(&dev->pm, &mlink->wcid);
 	mt76_connac_mcu_uni_add_dev(&dev->mphy, link_conf, &mconf->mt76,
 				    &mlink->wcid, false);
@@ -308,6 +304,19 @@ void mt792x_mac_link_bss_remove(struct mt792x_dev *dev,
 
 	mt76_wcid_cleanup(&dev->mt76, &mlink->wcid);
 }
+EXPORT_SYMBOL_GPL(__mt792x_mac_link_bss_remove);
+
+void mt792x_mac_link_bss_remove(struct mt792x_dev *dev,
+				struct mt792x_bss_conf *mconf,
+				struct mt792x_link_sta *mlink)
+{
+	struct ieee80211_vif *vif = container_of((void *)mconf->vif,
+						 struct ieee80211_vif, drv_priv);
+
+	__mt792x_mac_link_bss_remove(dev,
+				     mt792x_vif_to_bss_conf(vif, mconf->link_id),
+				     mconf, mlink);
+}
 EXPORT_SYMBOL_GPL(mt792x_mac_link_bss_remove);
 
 void mt792x_remove_interface(struct ieee80211_hw *hw,
-- 
2.47.3


  parent reply	other threads:[~2026-11-21 12:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-21 12:09 [PATCH mt76-next 01/17] wifi: mt76: mt7996: name a new secondary link to the firmware first Felix Fietkau
2026-11-21 12:09 ` [PATCH mt76-next 02/17] wifi: mt76: add a helper to point the TXQs of a station at a wcid Felix Fietkau
2026-11-21 12:09 ` [PATCH mt76-next 03/17] wifi: mt76: mt7925: move the default link to a remaining link Felix Fietkau
2026-11-21 12:09 ` [PATCH mt76-next 04/17] wifi: mt76: mt7925: keep the deflink wcid index until station removal Felix Fietkau
2026-11-21 12:09 ` [PATCH mt76-next 05/17] wifi: mt76: mt792x: look up the TX links under RCU Felix Fietkau
2026-11-21 12:09 ` [PATCH mt76-next 06/17] wifi: mt76: mt7925: read the links under RCU in the IPv6 notifier Felix Fietkau
2026-11-21 12:09 ` [PATCH mt76-next 07/17] wifi: mt76: mt7925: abort a ROC on the BSS that requested it Felix Fietkau
2026-11-21 12:09 ` Felix Fietkau [this message]
2026-11-21 12:09 ` [PATCH mt76-next 09/17] wifi: mt76: mt7925: send the MLO ROC only for a station vif Felix Fietkau
2026-11-21 12:09 ` [PATCH mt76-next 10/17] wifi: mt76: mt7996: send the Beacon rate table again after a full reset Felix Fietkau
2026-11-21 12:09 ` [PATCH mt76-next 11/17] wifi: mt76: mt7996: restore the operating channel after an L1 SER Felix Fietkau
2026-11-21 12:09 ` [PATCH mt76-next 12/17] wifi: mt76: reset the DFS state of a phy at a full reset Felix Fietkau
2026-11-21 12:09 ` [PATCH mt76-next 13/17] wifi: mt76: mt7996: abort a background CAC " Felix Fietkau
2026-11-21 12:09 ` [PATCH mt76-next 14/17] wifi: mt76: mt7915: " Felix Fietkau
2026-11-21 12:09 ` [PATCH mt76-next 15/17] wifi: mt76: mt7996: clear the airtime counts with the WTBL counters Felix Fietkau
2026-11-21 12:09 ` [PATCH mt76-next 16/17] wifi: mt76: mt7996: drop the host WTBL write of a fixed GI Felix Fietkau
2026-11-21 12:09 ` [PATCH mt76-next 17/17] wifi: mt76: mt7925: don't reset the USB device on probe Felix Fietkau

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=20261121120926.3603979-8-nbd@nbd.name \
    --to=nbd@nbd.name \
    --cc=linux-wireless@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox