wifi: mac80211: always initialize sdata::key_list
authorMiri Korenblit <miriam.rachel.korenblit@intel.com>
Wed, 9 Jul 2025 20:34:10 +0000 (23:34 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 10 Jul 2025 11:26:13 +0000 (13:26 +0200)
This is currently not initialized for a virtual monitor, leading to a
NULL pointer dereference when - for example - iterating over all the
keys of all the vifs.

Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20250709233400.8dcefe578497.I4c90a00ae3256520e063199d7f6f2580d5451acf@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/iface.c

index 7c27f3cd841c3cad37e91f62c04d2a75048ae7cf..c01634fdba789a86dfacf1a2fb34df4461ec33fc 100644 (file)
@@ -1150,6 +1150,8 @@ static void ieee80211_sdata_init(struct ieee80211_local *local,
 {
        sdata->local = local;
 
+       INIT_LIST_HEAD(&sdata->key_list);
+
        /*
         * Initialize the default link, so we can use link_id 0 for non-MLD,
         * and that continues to work for non-MLD-aware drivers that use just
@@ -2210,8 +2212,6 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
 
        ieee80211_init_frag_cache(&sdata->frags);
 
-       INIT_LIST_HEAD(&sdata->key_list);
-
        wiphy_delayed_work_init(&sdata->dec_tailroom_needed_wk,
                                ieee80211_delayed_tailroom_dec);