Skip to contentSkip to conversation

mac80211: Prevent unregistering of unregistered hw

PATCH Applied Ivo van Doorn 3 participants 4 messages Mar 23, 2007 mac80211

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mac80211: Prevent unregistering of unregistered hw

At the moment it is possible to call ieee80211_unregister_hw() for an unregistered hw structure. This will cause a big panic. This patch will add a BUG_ON() line to warn about this situation.

---

net/mac80211/ieee80211.c +3 -0
index 577dbe3..e7a613d 100644
@@ -4765,6 +4765,9 @@ void ieee80211_unregister_hw(struct ieee80211_hw *hw)
 	/* TODO: skb_queue should be empty here, no need to do anything? */
 
 	rtnl_lock();
+
+	BUG_ON(local->reg_state != IEEE80211_DEV_REGISTERED);
+
 	local->reg_state = IEEE80211_DEV_UNREGISTERED;
 	if (local->apdev)
 		ieee80211_if_del_mgmt(local);
maintainer
#1 lore raw

net/mac80211/ieee80211.c void ieee80211_unregister_hw(struct ieee80211_hw *hw) · line 4770

Quoted 11 lines · Ivo van Doorn
net/mac80211/ieee80211.c +3 -0
index 577dbe3..e7a613d 100644
@@ -4765,6 +4765,9 @@ void ieee80211_unregister_hw(struct ieee80211_hw *hw)
 	/* TODO: skb_queue should be empty here, no need to do anything? */
 
 	rtnl_lock();
+
+	BUG_ON(local->reg_state != IEEE80211_DEV_REGISTERED);
+

Hm. Maybe that's better since then there's no race like in my patch. Use this one instead of mine please. But it does kill the system pretty badly if you BUG_ON with rtnl held :)

johannes

Applied
#2 lore raw
Quoted 3 lines · Johannes Berg

Hm. Maybe that's better since then there's no race like in my patch. Use this one instead of mine please. But it does kill the system pretty badly if you BUG_ON with rtnl held :)

Who cares? ;-)

Applied, thanks for the patch.

Jiri

Signature · 2 lines
Jiri Benc
SUSE Labs
#3 lore raw
In reply to Johannes Berg
Quoted 9 lines · Johannes Berg
Quoted 7 lines · Ivo van Doorn
net/mac80211/ieee80211.c +0 -0
index 577dbe3..e7a613d 100644
@@ -4765,6 +4765,9 @@ void ieee80211_unregister_hw(struct ieee80211_hw *hw)
 	/* TODO: skb_queue should be empty here, no need to do anything? */
 
Quoted 8 lines

net/mac80211/ieee80211.c void ieee80211_unregister_hw(struct ieee80211_hw *hw) · line 4770

Quoted 4 lines
net/mac80211/ieee80211.c +3 -0
 	rtnl_lock();
+
+	BUG_ON(local->reg_state != IEEE80211_DEV_REGISTERED);
+

Hm. Maybe that's better since then there's no race like in my patch. Use this one instead of mine please. But it does kill the system pretty badly if you BUG_ON with rtnl held :)

Well it would increase motivation to fix such a bug in the driver then. ;) (yes, fixing that bug in rt2x00 is on my todo list :P)

Ivo