--- x/net/mac80211/sta_info.h +++ y/net/mac80211/sta_info.h @@ -705,7 +705,7 @@ struct sta_info { struct sta_ampdu_mlme ampdu_mlme; #ifdef CONFIG_MAC80211_DEBUGFS - struct dentry *debugfs_dir; + struct dentry *debugfs_dir, *pd; #endif u8 reserved_tid; --- x/net/mac80211/debugfs_sta.c +++ y/net/mac80211/debugfs_sta.c @@ -1252,6 +1252,7 @@ void ieee80211_sta_debugfs_add(struct st * dir might still be around. */ sta->debugfs_dir = debugfs_create_dir(mac, stations_dir); + sta->pd = stations_dir; DEBUGFS_ADD(flags); DEBUGFS_ADD(aid); @@ -1276,7 +1277,14 @@ void ieee80211_sta_debugfs_add(struct st void ieee80211_sta_debugfs_remove(struct sta_info *sta) { - debugfs_remove_recursive(sta->debugfs_dir); + struct dentry *stations_dir = sta->sdata->debugfs.subdir_stations; + + if (!sta->debugfs_dir) + return; + if (!stations_dir) + return; + if (sta->pd == stations_dir) + debugfs_remove_recursive(sta->debugfs_dir); sta->debugfs_dir = NULL; }