Skip to content

Commit 04414d7

Browse files
committed
wifi: mt76: mt7996: delete vif keys when requested
While deleting sta keys can be omitted in order to fix race conditions, vif keys must be deleted before being replaced in order to prevent accidental reuse in firmware. Link: https://patch.msgid.link/[email protected] Signed-off-by: Felix Fietkau <[email protected]>
1 parent 7c0f63f commit 04414d7

File tree

1 file changed

+13
-7
lines changed
  • drivers/net/wireless/mediatek/mt76/mt7996

1 file changed

+13
-7
lines changed

drivers/net/wireless/mediatek/mt76/mt7996/main.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,13 @@ mt7996_set_hw_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
252252
&link->mt76, msta_link, true);
253253
}
254254

255-
if (cmd == SET_KEY) {
255+
if (cmd == SET_KEY)
256256
*wcid_keyidx = idx;
257-
} else {
258-
if (idx == *wcid_keyidx)
259-
*wcid_keyidx = -1;
257+
else if (idx == *wcid_keyidx)
258+
*wcid_keyidx = -1;
259+
260+
if (cmd != SET_KEY && sta)
260261
continue;
261-
}
262262

263263
mt76_wcid_key_setup(&dev->mt76, &msta_link->wcid, key);
264264

@@ -277,10 +277,12 @@ mt7996_key_iter(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
277277
struct ieee80211_sta *sta, struct ieee80211_key_conf *key,
278278
void *data)
279279
{
280+
enum set_key_cmd *cmd = data;
281+
280282
if (sta)
281283
return;
282284

283-
WARN_ON(mt7996_set_hw_key(hw, SET_KEY, vif, NULL, key));
285+
WARN_ON(mt7996_set_hw_key(hw, *cmd, vif, NULL, key));
284286
}
285287

286288
int mt7996_vif_link_add(struct mt76_phy *mphy, struct ieee80211_vif *vif,
@@ -291,6 +293,7 @@ int mt7996_vif_link_add(struct mt76_phy *mphy, struct ieee80211_vif *vif,
291293
struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
292294
struct mt7996_sta_link *msta_link = &link->msta_link;
293295
struct mt7996_phy *phy = mphy->priv;
296+
enum set_key_cmd key_cmd = SET_KEY;
294297
struct mt7996_dev *dev = phy->dev;
295298
u8 band_idx = phy->mt76->band_idx;
296299
struct mt76_txq *mtxq;
@@ -370,7 +373,7 @@ int mt7996_vif_link_add(struct mt76_phy *mphy, struct ieee80211_vif *vif,
370373
CONN_STATE_PORT_SECURE, true);
371374
rcu_assign_pointer(dev->mt76.wcid[idx], &msta_link->wcid);
372375

373-
ieee80211_iter_keys(mphy->hw, vif, mt7996_key_iter, NULL);
376+
ieee80211_iter_keys(mphy->hw, vif, mt7996_key_iter, &key_cmd);
374377

375378
if (mvif->mt76.deflink_id == IEEE80211_LINK_UNSPECIFIED)
376379
mvif->mt76.deflink_id = link_conf->link_id;
@@ -385,10 +388,13 @@ void mt7996_vif_link_remove(struct mt76_phy *mphy, struct ieee80211_vif *vif,
385388
struct mt7996_vif_link *link = container_of(mlink, struct mt7996_vif_link, mt76);
386389
struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
387390
struct mt7996_sta_link *msta_link = &link->msta_link;
391+
enum set_key_cmd key_cmd = DISABLE_KEY;
388392
struct mt7996_phy *phy = mphy->priv;
389393
struct mt7996_dev *dev = phy->dev;
390394
int idx = msta_link->wcid.idx;
391395

396+
ieee80211_iter_keys(mphy->hw, vif, mt7996_key_iter, &key_cmd);
397+
392398
mt7996_mcu_add_sta(dev, link_conf, NULL, link, NULL,
393399
CONN_STATE_DISCONNECT, false);
394400
mt7996_mcu_add_bss_info(phy, vif, link_conf, mlink, msta_link, false);

0 commit comments

Comments
 (0)