diff options
author | Eric Dumazet <edumazet@google.com> | 2013-12-20 15:32:32 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-12-20 17:06:27 -0500 |
commit | a792866ad2dafb8f272e4fdfb98a93fdbfff2277 (patch) | |
tree | 37e9f71f8bd584aebc8002dc581d0e28c61d361f /net/sched/act_api.c | |
parent | dcd76081340da2f262a8c8efade200cc7554a3b9 (diff) |
net_sched: fix regression in tc_action_ops
list_for_each_entry(a, &act_base, head) doesn't
exit with a = NULL if we reached the end of the list.
tcf_unregister_action(), tc_lookup_action_n() and tc_lookup_action()
need fixes.
Remove tc_lookup_action_id() as its unused and not worth 'fixing'
Signed-off-by: Eric Dumazet <edumazet@google.com>
Fixes: 1f747c26c48b ("net_sched: convert tc_action_ops to use struct list_head")
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Reviewed-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/act_api.c')
-rw-r--r-- | net/sched/act_api.c | 53 |
1 files changed, 13 insertions, 40 deletions
diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 8114fef308d9..dce2b6ecdbd8 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c | |||
@@ -291,12 +291,12 @@ int tcf_unregister_action(struct tc_action_ops *act) | |||
291 | int err = -ENOENT; | 291 | int err = -ENOENT; |
292 | 292 | ||
293 | write_lock(&act_mod_lock); | 293 | write_lock(&act_mod_lock); |
294 | list_for_each_entry(a, &act_base, head) | 294 | list_for_each_entry(a, &act_base, head) { |
295 | if (a == act) | 295 | if (a == act) { |
296 | list_del(&act->head); | ||
297 | err = 0; | ||
296 | break; | 298 | break; |
297 | if (a) { | 299 | } |
298 | list_del(&act->head); | ||
299 | err = 0; | ||
300 | } | 300 | } |
301 | write_unlock(&act_mod_lock); | 301 | write_unlock(&act_mod_lock); |
302 | return err; | 302 | return err; |
@@ -306,68 +306,41 @@ EXPORT_SYMBOL(tcf_unregister_action); | |||
306 | /* lookup by name */ | 306 | /* lookup by name */ |
307 | static struct tc_action_ops *tc_lookup_action_n(char *kind) | 307 | static struct tc_action_ops *tc_lookup_action_n(char *kind) |
308 | { | 308 | { |
309 | struct tc_action_ops *a = NULL; | 309 | struct tc_action_ops *a, *res = NULL; |
310 | 310 | ||
311 | if (kind) { | 311 | if (kind) { |
312 | read_lock(&act_mod_lock); | 312 | read_lock(&act_mod_lock); |
313 | list_for_each_entry(a, &act_base, head) { | 313 | list_for_each_entry(a, &act_base, head) { |
314 | if (strcmp(kind, a->kind) == 0) { | 314 | if (strcmp(kind, a->kind) == 0) { |
315 | if (!try_module_get(a->owner)) { | 315 | if (try_module_get(a->owner)) |
316 | read_unlock(&act_mod_lock); | 316 | res = a; |
317 | return NULL; | ||
318 | } | ||
319 | break; | 317 | break; |
320 | } | 318 | } |
321 | } | 319 | } |
322 | read_unlock(&act_mod_lock); | 320 | read_unlock(&act_mod_lock); |
323 | } | 321 | } |
324 | return a; | 322 | return res; |
325 | } | 323 | } |
326 | 324 | ||
327 | /* lookup by nlattr */ | 325 | /* lookup by nlattr */ |
328 | static struct tc_action_ops *tc_lookup_action(struct nlattr *kind) | 326 | static struct tc_action_ops *tc_lookup_action(struct nlattr *kind) |
329 | { | 327 | { |
330 | struct tc_action_ops *a = NULL; | 328 | struct tc_action_ops *a, *res = NULL; |
331 | 329 | ||
332 | if (kind) { | 330 | if (kind) { |
333 | read_lock(&act_mod_lock); | 331 | read_lock(&act_mod_lock); |
334 | list_for_each_entry(a, &act_base, head) { | 332 | list_for_each_entry(a, &act_base, head) { |
335 | if (nla_strcmp(kind, a->kind) == 0) { | 333 | if (nla_strcmp(kind, a->kind) == 0) { |
336 | if (!try_module_get(a->owner)) { | 334 | if (try_module_get(a->owner)) |
337 | read_unlock(&act_mod_lock); | 335 | res = a; |
338 | return NULL; | ||
339 | } | ||
340 | break; | 336 | break; |
341 | } | 337 | } |
342 | } | 338 | } |
343 | read_unlock(&act_mod_lock); | 339 | read_unlock(&act_mod_lock); |
344 | } | 340 | } |
345 | return a; | 341 | return res; |
346 | } | 342 | } |
347 | 343 | ||
348 | #if 0 | ||
349 | /* lookup by id */ | ||
350 | static struct tc_action_ops *tc_lookup_action_id(u32 type) | ||
351 | { | ||
352 | struct tc_action_ops *a = NULL; | ||
353 | |||
354 | if (type) { | ||
355 | read_lock(&act_mod_lock); | ||
356 | for (a = act_base; a; a = a->next) { | ||
357 | if (a->type == type) { | ||
358 | if (!try_module_get(a->owner)) { | ||
359 | read_unlock(&act_mod_lock); | ||
360 | return NULL; | ||
361 | } | ||
362 | break; | ||
363 | } | ||
364 | } | ||
365 | read_unlock(&act_mod_lock); | ||
366 | } | ||
367 | return a; | ||
368 | } | ||
369 | #endif | ||
370 | |||
371 | int tcf_action_exec(struct sk_buff *skb, const struct list_head *actions, | 344 | int tcf_action_exec(struct sk_buff *skb, const struct list_head *actions, |
372 | struct tcf_result *res) | 345 | struct tcf_result *res) |
373 | { | 346 | { |