diff options
author | Denis V. Lunev <den@openvz.org> | 2007-11-11 01:12:03 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-11-11 01:12:03 -0500 |
commit | 2994c63863ac350c4c8c6a65d8110749c2abb95c (patch) | |
tree | 5509f71222641098683df1b1e0ff7bdfc2758b2c /net/ipv6/fib6_rules.c | |
parent | 33d36bb83c5b566c98a441e791736e25dbc35fc3 (diff) |
[INET]: Small possible memory leak in FIB rules
This patch fixes a small memory leak. Default fib rules can be deleted by
the user if the rule does not carry FIB_RULE_PERMANENT flag, f.e. by
ip rule flush
Such a rule will not be freed as the ref-counter has 2 on start and becomes
clearly unreachable after removal.
Signed-off-by: Denis V. Lunev <den@openvz.org>
Acked-by: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/fib6_rules.c')
-rw-r--r-- | net/ipv6/fib6_rules.c | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c index 706622af206f..428c6b0e26d8 100644 --- a/net/ipv6/fib6_rules.c +++ b/net/ipv6/fib6_rules.c | |||
@@ -31,25 +31,6 @@ struct fib6_rule | |||
31 | 31 | ||
32 | static struct fib_rules_ops fib6_rules_ops; | 32 | static struct fib_rules_ops fib6_rules_ops; |
33 | 33 | ||
34 | static struct fib6_rule main_rule = { | ||
35 | .common = { | ||
36 | .refcnt = ATOMIC_INIT(2), | ||
37 | .pref = 0x7FFE, | ||
38 | .action = FR_ACT_TO_TBL, | ||
39 | .table = RT6_TABLE_MAIN, | ||
40 | }, | ||
41 | }; | ||
42 | |||
43 | static struct fib6_rule local_rule = { | ||
44 | .common = { | ||
45 | .refcnt = ATOMIC_INIT(2), | ||
46 | .pref = 0, | ||
47 | .action = FR_ACT_TO_TBL, | ||
48 | .table = RT6_TABLE_LOCAL, | ||
49 | .flags = FIB_RULE_PERMANENT, | ||
50 | }, | ||
51 | }; | ||
52 | |||
53 | struct dst_entry *fib6_rule_lookup(struct flowi *fl, int flags, | 34 | struct dst_entry *fib6_rule_lookup(struct flowi *fl, int flags, |
54 | pol_lookup_t lookup) | 35 | pol_lookup_t lookup) |
55 | { | 36 | { |
@@ -270,11 +251,23 @@ static struct fib_rules_ops fib6_rules_ops = { | |||
270 | .owner = THIS_MODULE, | 251 | .owner = THIS_MODULE, |
271 | }; | 252 | }; |
272 | 253 | ||
273 | void __init fib6_rules_init(void) | 254 | static int __init fib6_default_rules_init(void) |
274 | { | 255 | { |
275 | list_add_tail(&local_rule.common.list, &fib6_rules_ops.rules_list); | 256 | int err; |
276 | list_add_tail(&main_rule.common.list, &fib6_rules_ops.rules_list); | 257 | |
258 | err = fib_default_rule_add(&fib6_rules_ops, 0, | ||
259 | RT6_TABLE_LOCAL, FIB_RULE_PERMANENT); | ||
260 | if (err < 0) | ||
261 | return err; | ||
262 | err = fib_default_rule_add(&fib6_rules_ops, 0x7FFE, RT6_TABLE_MAIN, 0); | ||
263 | if (err < 0) | ||
264 | return err; | ||
265 | return 0; | ||
266 | } | ||
277 | 267 | ||
268 | void __init fib6_rules_init(void) | ||
269 | { | ||
270 | BUG_ON(fib6_default_rules_init()); | ||
278 | fib_rules_register(&fib6_rules_ops); | 271 | fib_rules_register(&fib6_rules_ops); |
279 | } | 272 | } |
280 | 273 | ||