aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/ieee80211_rate.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2007-10-28 09:49:33 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-11-11 00:59:43 -0500
commit999acd9c339a761a18d625b13001612ac396ee00 (patch)
tree57498e6de24beb8a998e3a14743e8b7d73869e60 /net/mac80211/ieee80211_rate.c
parent2bf236d55e5ea2b92ed5235af09997c2995b316b (diff)
mac80211: don't allow registering the same rate control twice
Previously, mac80211 would allow registering the same rate control algorithm twice. This is a programming error in the registration and should not happen; additionally the second version could never be selected. Disallow this and warn about it. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/ieee80211_rate.c')
-rw-r--r--net/mac80211/ieee80211_rate.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/net/mac80211/ieee80211_rate.c b/net/mac80211/ieee80211_rate.c
index e4bd8481554d..7254bd609839 100644
--- a/net/mac80211/ieee80211_rate.c
+++ b/net/mac80211/ieee80211_rate.c
@@ -28,13 +28,22 @@ int ieee80211_rate_control_register(struct rate_control_ops *ops)
28 if (!ops->name) 28 if (!ops->name)
29 return -EINVAL; 29 return -EINVAL;
30 30
31 mutex_lock(&rate_ctrl_mutex);
32 list_for_each_entry(alg, &rate_ctrl_algs, list) {
33 if (!strcmp(alg->ops->name, ops->name)) {
34 /* don't register an algorithm twice */
35 WARN_ON(1);
36 return -EALREADY;
37 }
38 }
39
31 alg = kzalloc(sizeof(*alg), GFP_KERNEL); 40 alg = kzalloc(sizeof(*alg), GFP_KERNEL);
32 if (alg == NULL) { 41 if (alg == NULL) {
42 mutex_unlock(&rate_ctrl_mutex);
33 return -ENOMEM; 43 return -ENOMEM;
34 } 44 }
35 alg->ops = ops; 45 alg->ops = ops;
36 46
37 mutex_lock(&rate_ctrl_mutex);
38 list_add_tail(&alg->list, &rate_ctrl_algs); 47 list_add_tail(&alg->list, &rate_ctrl_algs);
39 mutex_unlock(&rate_ctrl_mutex); 48 mutex_unlock(&rate_ctrl_mutex);
40 49