--- x/net/mac80211/debugfs_netdev.c +++ y/net/mac80211/debugfs_netdev.c @@ -1016,12 +1016,15 @@ static void ieee80211_debugfs_add_netdev void ieee80211_debugfs_remove_netdev(struct ieee80211_sub_if_data *sdata) { + mutex_lock(&sdata->debug_mutex); if (!sdata->vif.debugfs_dir) - return; + goto out; debugfs_remove_recursive(sdata->vif.debugfs_dir); sdata->vif.debugfs_dir = NULL; sdata->debugfs.subdir_stations = NULL; +out: + mutex_unlock(&sdata->debug_mutex); } void ieee80211_debugfs_rename_netdev(struct ieee80211_sub_if_data *sdata) --- x/net/mac80211/debugfs_sta.c +++ y/net/mac80211/debugfs_sta.c @@ -1284,8 +1284,13 @@ void ieee80211_sta_debugfs_add(struct st void ieee80211_sta_debugfs_remove(struct sta_info *sta) { - debugfs_remove_recursive(sta->debugfs_dir); + struct ieee80211_sub_if_data *sdata = sta->sdata; + + mutex_lock(&sdata->debug_mutex); + if (sdata->debugfs.subdir_stations != NULL) + debugfs_remove_recursive(sta->debugfs_dir); sta->debugfs_dir = NULL; + mutex_unlock(&sdata->debug_mutex); } #undef DEBUGFS_ADD --- x/net/mac80211/ieee80211_i.h +++ y/net/mac80211/ieee80211_i.h @@ -1172,6 +1172,7 @@ struct ieee80211_sub_if_data { u16 desired_active_links; u16 restart_active_links; + struct mutex debug_mutex; #ifdef CONFIG_MAC80211_DEBUGFS struct { --- x/net/mac80211/iface.c +++ y/net/mac80211/iface.c @@ -1091,6 +1091,7 @@ static void ieee80211_set_default_queues static void ieee80211_sdata_init(struct ieee80211_local *local, struct ieee80211_sub_if_data *sdata) { + mutex_init(&sdata->debug_mutex); sdata->local = local; /*