Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mac80211_hwsim: fix use after free

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>

authored by

Johannes Berg and committed by
John W. Linville
e603d9d8 5d416351

+2 -2
+2 -2
drivers/net/wireless/mac80211_hwsim.c
··· 709 709 static void mac80211_hwsim_free(void) 710 710 { 711 711 struct list_head tmplist, *i, *tmp; 712 - struct mac80211_hwsim_data *data; 712 + struct mac80211_hwsim_data *data, *tmpdata; 713 713 714 714 INIT_LIST_HEAD(&tmplist); 715 715 ··· 718 718 list_move(i, &tmplist); 719 719 spin_unlock_bh(&hwsim_radio_lock); 720 720 721 - list_for_each_entry(data, &tmplist, list) { 721 + list_for_each_entry_safe(data, tmpdata, &tmplist, list) { 722 722 debugfs_remove(data->debugfs_group); 723 723 debugfs_remove(data->debugfs_ps); 724 724 debugfs_remove(data->debugfs);