@@ -472,15 +472,19 @@ int wiphy_register(struct wiphy *wiphy)
/* check and set up bitrates */
ieee80211_set_bitrate_flags(wiphy);
+ mutex_lock(&cfg80211_mutex);
+
res = device_add(&rdev->wiphy.dev);
- if (res)
+ if (res) {
+ mutex_unlock(&cfg80211_mutex);
return res;
+ }
res = rfkill_register(rdev->rfkill);
- if (res)
+ if (res) {
+ mutex_unlock(&cfg80211_mutex);
goto out_rm_dev;
-
- mutex_lock(&cfg80211_mutex);
+ }
/* set up regulatory info */
wiphy_update_regulatory(wiphy, NL80211_REGDOM_SET_BY_CORE);