Skip to contentSkip to conversation

mac80211: fix SMPS debugfs locking

PATCH New Johannes Berg 1 participant 1 message Apr 19, 2011 mac80211

lore
Share & tools
lore

Johannes Berg

author maintainer
#0 lore raw

PATCH 1/1 mac80211: fix SMPS debugfs locking

From: Johannes Berg <[email protected]>

The locking with SMPS requests means that the debugs file should lock the mgd mutex, not the iflist mutex. Calls to __ieee80211_request_smps() need to hold that mutex, so add an assertion.

This has always been wrong, but for some reason never been noticed, probably because the locking error only happens while unassociated.

---
 net/mac80211/cfg.c            |    2 ++
 net/mac80211/debugfs_netdev.c |    4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)
net/mac80211/debugfs_netdev.c +2 -2
@@ -177,9 +177,9 @@ static int ieee80211_set_smps(struct iee
 	if (sdata->vif.type != NL80211_IFTYPE_STATION)
 		return -EOPNOTSUPP;
 
-	mutex_lock(&local->iflist_mtx);
+	mutex_lock(&sdata->u.mgd.mtx);
 	err = __ieee80211_request_smps(sdata, smps_mode);
-	mutex_unlock(&local->iflist_mtx);
+	mutex_unlock(&sdata->u.mgd.mtx);
 
 	return err;
 }
net/mac80211/cfg.c +2 -0
@@ -1526,6 +1526,8 @@ int __ieee80211_request_smps(struct ieee
 	enum ieee80211_smps_mode old_req;
 	int err;
 
+	lockdep_assert_held(&sdata->u.mgd.mtx);
+
 	old_req = sdata->u.mgd.req_smps;
 	sdata->u.mgd.req_smps = smps_mode;