wifi: mt76: mt7925: switch link STA allocation to RCU lifetime

Allocate mt792x_link_sta with kzalloc() and free it with kfree_rcu()
instead of devm-managed memory.

msta->link[] is published via RCU, so the link STA must remain valid
until readers have quiesced after teardown. Manage the object lifetime
with kfree_rcu() to match its RCU-visible publication.

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Link: https://patch.msgid.link/20260306232238.2039675-18-sean.wang@kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
Sean Wang 2026-03-06 17:22:36 -06:00 committed by Felix Fietkau
parent 52f088a2e6
commit 6ace866cf6
2 changed files with 8 additions and 3 deletions

View File

@ -1005,7 +1005,7 @@ mt7925_mac_sta_add_links(struct mt792x_dev *dev, struct ieee80211_vif *vif,
mlink = &msta->deflink;
msta->deflink_id = link_id;
} else {
mlink = devm_kzalloc(dev->mt76.dev, sizeof(*mlink), GFP_KERNEL);
mlink = kzalloc(sizeof(*mlink), GFP_KERNEL);
if (!mlink) {
err = -ENOMEM;
break;
@ -1197,6 +1197,7 @@ mt7925_mac_sta_remove_links(struct mt792x_dev *dev, struct ieee80211_vif *vif,
struct ieee80211_sta *sta, unsigned long old_links)
{
struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;
struct mt76_dev *mdev = &dev->mt76;
unsigned int link_id;
/* clean up bss before starec */
@ -1235,17 +1236,20 @@ mt7925_mac_sta_remove_links(struct mt792x_dev *dev, struct ieee80211_vif *vif,
if (!link_sta)
continue;
mlink = mt792x_sta_to_link(msta, link_id);
mlink = rcu_replace_pointer(msta->link[link_id], NULL,
lockdep_is_held(&mdev->mutex));
if (!mlink)
continue;
rcu_assign_pointer(msta->link[link_id], NULL);
msta->valid_links &= ~BIT(link_id);
mlink->sta = NULL;
mlink->pri_link = NULL;
mt7925_mac_link_sta_remove(&dev->mt76, vif, link_sta, mlink);
if (mlink != &msta->deflink)
kfree_rcu(mlink, rcu_head);
if (msta->deflink_id == link_id)
msta->deflink_id = IEEE80211_LINK_UNSPECIFIED;
}

View File

@ -97,6 +97,7 @@ DECLARE_EWMA(avg_signal, 10, 8)
struct mt792x_link_sta {
struct mt76_wcid wcid; /* must be first */
struct rcu_head rcu_head;
u32 airtime_ac[8];