diff --git a/mt7925/main.c b/mt7925/main.c index 307850a58..dcfd64c23 100644 --- a/mt7925/main.c +++ b/mt7925/main.c @@ -604,6 +604,17 @@ static int mt7925_set_link_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, link_sta = sta ? mt792x_sta_to_link_sta(vif, sta, link_id) : NULL; mconf = mt792x_vif_to_link(mvif, link_id); mlink = mt792x_sta_to_link(msta, link_id); + + if (!link_conf || !mconf || !mlink) { + /* During MLO roaming, link state may be torn down before + * mac80211 requests key removal. If removing a key and + * the link is already gone, consider it successfully removed. + */ + if (cmd != SET_KEY) + return 0; + return -EINVAL; + } + wcid = &mlink->wcid; wcid_keyidx = &wcid->hw_key_idx;