aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/wireless/core.c5
-rw-r--r--net/wireless/core.h7
2 files changed, 11 insertions, 1 deletions
diff --git a/net/wireless/core.c b/net/wireless/core.c
index 2b3e786ec53f..35d457b2751e 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -42,6 +42,9 @@ cfg80211_drv_by_wiphy_idx(int wiphy_idx)
42{ 42{
43 struct cfg80211_registered_device *result = NULL, *drv; 43 struct cfg80211_registered_device *result = NULL, *drv;
44 44
45 if (!wiphy_idx_valid(wiphy_idx))
46 return NULL;
47
45 list_for_each_entry(drv, &cfg80211_drv_list, list) { 48 list_for_each_entry(drv, &cfg80211_drv_list, list) {
46 if (drv->wiphy_idx == wiphy_idx) { 49 if (drv->wiphy_idx == wiphy_idx) {
47 result = drv; 50 result = drv;
@@ -225,7 +228,7 @@ struct wiphy *wiphy_new(struct cfg80211_ops *ops, int sizeof_priv)
225 228
226 drv->wiphy_idx = wiphy_counter++; 229 drv->wiphy_idx = wiphy_counter++;
227 230
228 if (unlikely(drv->wiphy_idx < 0)) { 231 if (unlikely(!wiphy_idx_valid(drv->wiphy_idx))) {
229 wiphy_counter--; 232 wiphy_counter--;
230 mutex_unlock(&cfg80211_drv_mutex); 233 mutex_unlock(&cfg80211_drv_mutex);
231 /* ugh, wrapped! */ 234 /* ugh, wrapped! */
diff --git a/net/wireless/core.h b/net/wireless/core.h
index 178378124800..4f2e0fe38ce3 100644
--- a/net/wireless/core.h
+++ b/net/wireless/core.h
@@ -63,6 +63,13 @@ struct cfg80211_registered_device *wiphy_to_dev(struct wiphy *wiphy)
63 return container_of(wiphy, struct cfg80211_registered_device, wiphy); 63 return container_of(wiphy, struct cfg80211_registered_device, wiphy);
64} 64}
65 65
66/* Note 0 is valid, hence phy0 */
67static inline
68bool wiphy_idx_valid(int wiphy_idx)
69{
70 return (wiphy_idx >= 0);
71}
72
66extern struct mutex cfg80211_drv_mutex; 73extern struct mutex cfg80211_drv_mutex;
67extern struct list_head cfg80211_drv_list; 74extern struct list_head cfg80211_drv_list;
68 75