Skip to content

Commit

Permalink
[NETFILTER]: nf_conntrack: Fix module refcount dropping too far
Browse files Browse the repository at this point in the history
If nf_ct_l3proto_find_get() fails to get the refcount of
nf_ct_l3proto_generic, nf_ct_l3proto_put() will drop the refcount
too far.

This gets rid of '.me = THIS_MODULE' of nf_ct_l3proto_generic so that
nf_ct_l3proto_find_get() doesn't try to get refcount of it.
It's OK because its symbol is usable until nf_conntrack.ko is unloaded.

This also kills unnecessary NULL pointer check as well.
__nf_ct_proto_find() allways returns non-NULL pointer.

Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Yasuyuki Kozakai authored and David S. Miller committed Apr 25, 2006
1 parent d8fe3f1 commit e1bbdeb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
12 changes: 4 additions & 8 deletions net/netfilter/nf_conntrack_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,8 @@ nf_ct_proto_find_get(u_int16_t l3proto, u_int8_t protocol)

preempt_disable();
p = __nf_ct_proto_find(l3proto, protocol);
if (p) {
if (!try_module_get(p->me))
p = &nf_conntrack_generic_protocol;
}
if (!try_module_get(p->me))
p = &nf_conntrack_generic_protocol;
preempt_enable();

return p;
Expand All @@ -229,10 +227,8 @@ nf_ct_l3proto_find_get(u_int16_t l3proto)

preempt_disable();
p = __nf_ct_l3proto_find(l3proto);
if (p) {
if (!try_module_get(p->me))
p = &nf_conntrack_generic_l3proto;
}
if (!try_module_get(p->me))
p = &nf_conntrack_generic_l3proto;
preempt_enable();

return p;
Expand Down
1 change: 0 additions & 1 deletion net/netfilter/nf_conntrack_l3proto_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,4 @@ struct nf_conntrack_l3proto nf_conntrack_generic_l3proto = {
.print_conntrack = generic_print_conntrack,
.prepare = generic_prepare,
.get_features = generic_get_features,
.me = THIS_MODULE,
};

0 comments on commit e1bbdeb

Please sign in to comment.