mirror of
https://github.com/FEX-Emu/linux.git
synced 2025-02-04 18:18:54 +00:00
net_sched: fix a regression in tcf_proto_lookup_ops()
list_for_each_entry(t, &tcf_proto_base, head) doesn't exit with t = NULL if we reached the end of the list. Signed-off-by: Eric Dumazet <edumazet@google.com> Fixes: 3627287463b4 ("net_sched: convert tcf_proto_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>
This commit is contained in:
parent
568a153a22
commit
dcd7608134
@ -40,20 +40,20 @@ static DEFINE_RWLOCK(cls_mod_lock);
|
|||||||
|
|
||||||
static const struct tcf_proto_ops *tcf_proto_lookup_ops(struct nlattr *kind)
|
static const struct tcf_proto_ops *tcf_proto_lookup_ops(struct nlattr *kind)
|
||||||
{
|
{
|
||||||
const struct tcf_proto_ops *t = NULL;
|
const struct tcf_proto_ops *t, *res = NULL;
|
||||||
|
|
||||||
if (kind) {
|
if (kind) {
|
||||||
read_lock(&cls_mod_lock);
|
read_lock(&cls_mod_lock);
|
||||||
list_for_each_entry(t, &tcf_proto_base, head) {
|
list_for_each_entry(t, &tcf_proto_base, head) {
|
||||||
if (nla_strcmp(kind, t->kind) == 0) {
|
if (nla_strcmp(kind, t->kind) == 0) {
|
||||||
if (!try_module_get(t->owner))
|
if (try_module_get(t->owner))
|
||||||
t = NULL;
|
res = t;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
read_unlock(&cls_mod_lock);
|
read_unlock(&cls_mod_lock);
|
||||||
}
|
}
|
||||||
return t;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Register(unregister) new classifier type */
|
/* Register(unregister) new classifier type */
|
||||||
@ -82,15 +82,13 @@ int unregister_tcf_proto_ops(struct tcf_proto_ops *ops)
|
|||||||
int rc = -ENOENT;
|
int rc = -ENOENT;
|
||||||
|
|
||||||
write_lock(&cls_mod_lock);
|
write_lock(&cls_mod_lock);
|
||||||
list_for_each_entry(t, &tcf_proto_base, head)
|
list_for_each_entry(t, &tcf_proto_base, head) {
|
||||||
if (t == ops)
|
if (t == ops) {
|
||||||
|
list_del(&t->head);
|
||||||
|
rc = 0;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
if (!t)
|
}
|
||||||
goto out;
|
|
||||||
list_del(&t->head);
|
|
||||||
rc = 0;
|
|
||||||
out:
|
|
||||||
write_unlock(&cls_mod_lock);
|
write_unlock(&cls_mod_lock);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user