aboutsummaryrefslogtreecommitdiffstats
path: root/net/netfilter
diff options
context:
space:
mode:
authorGao feng <gaofeng@cn.fujitsu.com>2012-06-21 00:36:42 -0400
committerPablo Neira Ayuso <pablo@netfilter.org>2012-06-27 12:55:22 -0400
commit12c26df35eae52f14cf573a1adb85cedaa273d2b (patch)
treec5a75e79d0bd95de70d1db4f5c8a4c3a5f6a73b8 /net/netfilter
parentfa34fff5e69cc56eecf26754c9b57403899ebd0d (diff)
netfilter: nf_conntrack: fix memory leak if sysctl registration fails
In nf_ct_l4proto_register_sysctl, if l4proto sysctl registration fails, we have to make sure that we release the compat sysctl table. This can happen if TCP has been registered compat for IPv4, and IPv6 compat registration fails. Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net/netfilter')
-rw-r--r--net/netfilter/nf_conntrack_proto.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
index 63612e6d7238..21b850c4b3ab 100644
--- a/net/netfilter/nf_conntrack_proto.c
+++ b/net/netfilter/nf_conntrack_proto.c
@@ -341,11 +341,14 @@ int nf_ct_l4proto_register_sysctl(struct net *net,
341 kfree(pn->ctl_table); 341 kfree(pn->ctl_table);
342 pn->ctl_table = NULL; 342 pn->ctl_table = NULL;
343 } 343 }
344 goto out;
345 } 344 }
346 } 345 }
347#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT 346#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
348 if (l4proto->l3proto != AF_INET6 && pn->ctl_compat_table != NULL) { 347 if (l4proto->l3proto != AF_INET6 && pn->ctl_compat_table != NULL) {
348 if (err < 0) {
349 nf_ct_kfree_compat_sysctl_table(pn);
350 goto out;
351 }
349 err = nf_ct_register_sysctl(net, 352 err = nf_ct_register_sysctl(net,
350 &pn->ctl_compat_header, 353 &pn->ctl_compat_header,
351 "net/ipv4/netfilter", 354 "net/ipv4/netfilter",
@@ -358,8 +361,8 @@ int nf_ct_l4proto_register_sysctl(struct net *net,
358 &pn->ctl_table, 361 &pn->ctl_table,
359 pn->users); 362 pn->users);
360 } 363 }
361#endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */
362out: 364out:
365#endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */
363#endif /* CONFIG_SYSCTL */ 366#endif /* CONFIG_SYSCTL */
364 return err; 367 return err;
365} 368}