Skip to content

Commit

Permalink
mac80211: don't allow registering the same rate control twice
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johannes Berg authored and David S. Miller committed Nov 11, 2007
1 parent 2bf236d commit 999acd9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion net/mac80211/ieee80211_rate.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,22 @@ int ieee80211_rate_control_register(struct rate_control_ops *ops)
if (!ops->name)
return -EINVAL;

mutex_lock(&rate_ctrl_mutex);
list_for_each_entry(alg, &rate_ctrl_algs, list) {
if (!strcmp(alg->ops->name, ops->name)) {
/* don't register an algorithm twice */
WARN_ON(1);
return -EALREADY;
}
}

alg = kzalloc(sizeof(*alg), GFP_KERNEL);
if (alg == NULL) {
mutex_unlock(&rate_ctrl_mutex);
return -ENOMEM;
}
alg->ops = ops;

mutex_lock(&rate_ctrl_mutex);
list_add_tail(&alg->list, &rate_ctrl_algs);
mutex_unlock(&rate_ctrl_mutex);

Expand Down

0 comments on commit 999acd9

Please sign in to comment.