diff options
Diffstat (limited to 'net/mac80211/cfg.c')
-rw-r--r-- | net/mac80211/cfg.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index f8c49c5ad8aa..952845e7072a 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c | |||
@@ -120,6 +120,9 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev, | |||
120 | struct ieee80211_key *key; | 120 | struct ieee80211_key *key; |
121 | int err; | 121 | int err; |
122 | 122 | ||
123 | if (!netif_running(dev)) | ||
124 | return -ENETDOWN; | ||
125 | |||
123 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 126 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
124 | 127 | ||
125 | switch (params->cipher) { | 128 | switch (params->cipher) { |
@@ -145,7 +148,7 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev, | |||
145 | if (!key) | 148 | if (!key) |
146 | return -ENOMEM; | 149 | return -ENOMEM; |
147 | 150 | ||
148 | rcu_read_lock(); | 151 | mutex_lock(&sdata->local->sta_mtx); |
149 | 152 | ||
150 | if (mac_addr) { | 153 | if (mac_addr) { |
151 | sta = sta_info_get_bss(sdata, mac_addr); | 154 | sta = sta_info_get_bss(sdata, mac_addr); |
@@ -160,7 +163,7 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev, | |||
160 | 163 | ||
161 | err = 0; | 164 | err = 0; |
162 | out_unlock: | 165 | out_unlock: |
163 | rcu_read_unlock(); | 166 | mutex_unlock(&sdata->local->sta_mtx); |
164 | 167 | ||
165 | return err; | 168 | return err; |
166 | } | 169 | } |
@@ -174,7 +177,7 @@ static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev, | |||
174 | 177 | ||
175 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 178 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
176 | 179 | ||
177 | rcu_read_lock(); | 180 | mutex_lock(&sdata->local->sta_mtx); |
178 | 181 | ||
179 | if (mac_addr) { | 182 | if (mac_addr) { |
180 | ret = -ENOENT; | 183 | ret = -ENOENT; |
@@ -202,7 +205,7 @@ static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev, | |||
202 | 205 | ||
203 | ret = 0; | 206 | ret = 0; |
204 | out_unlock: | 207 | out_unlock: |
205 | rcu_read_unlock(); | 208 | mutex_unlock(&sdata->local->sta_mtx); |
206 | 209 | ||
207 | return ret; | 210 | return ret; |
208 | } | 211 | } |
@@ -305,15 +308,10 @@ static int ieee80211_config_default_key(struct wiphy *wiphy, | |||
305 | struct net_device *dev, | 308 | struct net_device *dev, |
306 | u8 key_idx) | 309 | u8 key_idx) |
307 | { | 310 | { |
308 | struct ieee80211_sub_if_data *sdata; | 311 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
309 | |||
310 | rcu_read_lock(); | ||
311 | 312 | ||
312 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
313 | ieee80211_set_default_key(sdata, key_idx); | 313 | ieee80211_set_default_key(sdata, key_idx); |
314 | 314 | ||
315 | rcu_read_unlock(); | ||
316 | |||
317 | return 0; | 315 | return 0; |
318 | } | 316 | } |
319 | 317 | ||