mac80211_hwsim: fix use after free
authorJohannes Berg <johannes@sipsolutions.net>
Mon, 13 Jul 2009 11:25:58 +0000 (13:25 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Tue, 21 Jul 2009 16:07:40 +0000 (12:07 -0400)
Once the "data" pointer is freed, we can't be iterating
to the next item in the list any more so we need to use
list_for_each_entry_safe with a temporary variable.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/mac80211_hwsim.c

index 5bed8241f3ccb87bcabb44440e3116ac0a31c50a..7916ca3f84c8892420bcca591c9c3c122386a213 100644 (file)
@@ -709,7 +709,7 @@ static const struct ieee80211_ops mac80211_hwsim_ops =
 static void mac80211_hwsim_free(void)
 {
        struct list_head tmplist, *i, *tmp;
-       struct mac80211_hwsim_data *data;
+       struct mac80211_hwsim_data *data, *tmpdata;
 
        INIT_LIST_HEAD(&tmplist);
 
@@ -718,7 +718,7 @@ static void mac80211_hwsim_free(void)
                list_move(i, &tmplist);
        spin_unlock_bh(&hwsim_radio_lock);
 
-       list_for_each_entry(data, &tmplist, list) {
+       list_for_each_entry_safe(data, tmpdata, &tmplist, list) {
                debugfs_remove(data->debugfs_group);
                debugfs_remove(data->debugfs_ps);
                debugfs_remove(data->debugfs);