mirror of
https://github.com/outbackdingo/mt76.git
synced 2026-10-24 13:26:48 +00:00
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Felix Fietkau <[email protected]>
This commit is contained in:
+7
-3
@@ -1005,7 +1005,7 @@ mt7925_mac_sta_add_links(struct mt792x_dev *dev, struct ieee80211_vif *vif,
|
|||||||
mlink = &msta->deflink;
|
mlink = &msta->deflink;
|
||||||
msta->deflink_id = link_id;
|
msta->deflink_id = link_id;
|
||||||
} else {
|
} else {
|
||||||
mlink = devm_kzalloc(dev->mt76.dev, sizeof(*mlink), GFP_KERNEL);
|
mlink = kzalloc(sizeof(*mlink), GFP_KERNEL);
|
||||||
if (!mlink) {
|
if (!mlink) {
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
break;
|
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 ieee80211_sta *sta, unsigned long old_links)
|
||||||
{
|
{
|
||||||
struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;
|
struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;
|
||||||
|
struct mt76_dev *mdev = &dev->mt76;
|
||||||
unsigned int link_id;
|
unsigned int link_id;
|
||||||
|
|
||||||
/* clean up bss before starec */
|
/* 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)
|
if (!link_sta)
|
||||||
continue;
|
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)
|
if (!mlink)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
rcu_assign_pointer(msta->link[link_id], NULL);
|
|
||||||
msta->valid_links &= ~BIT(link_id);
|
msta->valid_links &= ~BIT(link_id);
|
||||||
mlink->sta = NULL;
|
mlink->sta = NULL;
|
||||||
mlink->pri_link = NULL;
|
mlink->pri_link = NULL;
|
||||||
|
|
||||||
mt7925_mac_link_sta_remove(&dev->mt76, vif, link_sta, mlink);
|
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)
|
if (msta->deflink_id == link_id)
|
||||||
msta->deflink_id = IEEE80211_LINK_UNSPECIFIED;
|
msta->deflink_id = IEEE80211_LINK_UNSPECIFIED;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user