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

wifi: mac80211: take wiphy lock for MAC addr change

We want to ensure everything holds the wiphy lock,
so also extend that to the MAC change callback.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>

+16 -3
+16 -3
net/mac80211/iface.c
··· 251 251 return ret; 252 252 } 253 253 254 - static int ieee80211_change_mac(struct net_device *dev, void *addr) 254 + static int _ieee80211_change_mac(struct ieee80211_sub_if_data *sdata, 255 + void *addr) 255 256 { 256 - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 257 257 struct ieee80211_local *local = sdata->local; 258 258 struct sockaddr *sa = addr; 259 259 bool check_dup = true; ··· 278 278 279 279 if (live) 280 280 drv_remove_interface(local, sdata); 281 - ret = eth_mac_addr(dev, sa); 281 + ret = eth_mac_addr(sdata->dev, sa); 282 282 283 283 if (ret == 0) { 284 284 memcpy(sdata->vif.addr, sa->sa_data, ETH_ALEN); ··· 290 290 */ 291 291 if (live) 292 292 WARN_ON(drv_add_interface(local, sdata)); 293 + 294 + return ret; 295 + } 296 + 297 + static int ieee80211_change_mac(struct net_device *dev, void *addr) 298 + { 299 + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 300 + struct ieee80211_local *local = sdata->local; 301 + int ret; 302 + 303 + wiphy_lock(local->hw.wiphy); 304 + ret = _ieee80211_change_mac(sdata, addr); 305 + wiphy_unlock(local->hw.wiphy); 293 306 294 307 return ret; 295 308 }