aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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