aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/cfg.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/mac80211/cfg.c')
-rw-r--r--net/mac80211/cfg.c38
1 files changed, 15 insertions, 23 deletions
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index ed3400cd7a5a..94690366321c 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -160,13 +160,14 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
160static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev, 160static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
161 u8 key_idx, bool pairwise, const u8 *mac_addr) 161 u8 key_idx, bool pairwise, const u8 *mac_addr)
162{ 162{
163 struct ieee80211_sub_if_data *sdata; 163 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
164 struct ieee80211_local *local = sdata->local;
164 struct sta_info *sta; 165 struct sta_info *sta;
166 struct ieee80211_key *key = NULL;
165 int ret; 167 int ret;
166 168
167 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 169 mutex_lock(&local->sta_mtx);
168 170 mutex_lock(&local->key_mtx);
169 mutex_lock(&sdata->local->sta_mtx);
170 171
171 if (mac_addr) { 172 if (mac_addr) {
172 ret = -ENOENT; 173 ret = -ENOENT;
@@ -175,33 +176,24 @@ static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
175 if (!sta) 176 if (!sta)
176 goto out_unlock; 177 goto out_unlock;
177 178
178 if (pairwise) { 179 if (pairwise)
179 if (sta->ptk) { 180 key = sta->ptk;
180 ieee80211_key_free(sdata->local, sta->ptk); 181 else
181 ret = 0; 182 key = sta->gtk[key_idx];
182 } 183 } else
183 } else { 184 key = sdata->keys[key_idx];
184 if (sta->gtk[key_idx]) {
185 ieee80211_key_free(sdata->local,
186 sta->gtk[key_idx]);
187 ret = 0;
188 }
189 }
190
191 goto out_unlock;
192 }
193 185
194 if (!sdata->keys[key_idx]) { 186 if (!key) {
195 ret = -ENOENT; 187 ret = -ENOENT;
196 goto out_unlock; 188 goto out_unlock;
197 } 189 }
198 190
199 ieee80211_key_free(sdata->local, sdata->keys[key_idx]); 191 __ieee80211_key_free(key);
200 WARN_ON(sdata->keys[key_idx]);
201 192
202 ret = 0; 193 ret = 0;
203 out_unlock: 194 out_unlock:
204 mutex_unlock(&sdata->local->sta_mtx); 195 mutex_unlock(&local->key_mtx);
196 mutex_unlock(&local->sta_mtx);
205 197
206 return ret; 198 return ret;
207} 199}