]>
Commit | Line | Data |
---|---|---|
abfbd08a GKH |
1 | From c6fd6477f525bf75a673dcfb5a51c43b8c3e05c7 Mon Sep 17 00:00:00 2001 |
2 | From: Hong Zhiguo <honkiko@gmail.com> | |
3 | Date: Tue, 26 Mar 2013 01:52:45 +0800 | |
4 | Subject: ipv6: fix bad free of addrconf_init_net | |
5 | ||
6 | ||
7 | From: Hong Zhiguo <honkiko@gmail.com> | |
8 | ||
9 | [ Upstream commit a79ca223e029aa4f09abb337accf1812c900a800 ] | |
10 | ||
11 | Signed-off-by: Hong Zhiguo <honkiko@gmail.com> | |
12 | Signed-off-by: David S. Miller <davem@davemloft.net> | |
13 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
14 | --- | |
15 | net/ipv6/addrconf.c | 26 ++++++++++---------------- | |
16 | 1 file changed, 10 insertions(+), 16 deletions(-) | |
17 | ||
18 | --- a/net/ipv6/addrconf.c | |
19 | +++ b/net/ipv6/addrconf.c | |
20 | @@ -4686,26 +4686,20 @@ static void addrconf_sysctl_unregister(s | |
21 | ||
22 | static int __net_init addrconf_init_net(struct net *net) | |
23 | { | |
24 | - int err; | |
25 | + int err = -ENOMEM; | |
26 | struct ipv6_devconf *all, *dflt; | |
27 | ||
28 | - err = -ENOMEM; | |
29 | - all = &ipv6_devconf; | |
30 | - dflt = &ipv6_devconf_dflt; | |
31 | + all = kmemdup(&ipv6_devconf, sizeof(ipv6_devconf), GFP_KERNEL); | |
32 | + if (all == NULL) | |
33 | + goto err_alloc_all; | |
34 | ||
35 | - if (!net_eq(net, &init_net)) { | |
36 | - all = kmemdup(all, sizeof(ipv6_devconf), GFP_KERNEL); | |
37 | - if (all == NULL) | |
38 | - goto err_alloc_all; | |
39 | + dflt = kmemdup(&ipv6_devconf_dflt, sizeof(ipv6_devconf_dflt), GFP_KERNEL); | |
40 | + if (dflt == NULL) | |
41 | + goto err_alloc_dflt; | |
42 | ||
43 | - dflt = kmemdup(dflt, sizeof(ipv6_devconf_dflt), GFP_KERNEL); | |
44 | - if (dflt == NULL) | |
45 | - goto err_alloc_dflt; | |
46 | - } else { | |
47 | - /* these will be inherited by all namespaces */ | |
48 | - dflt->autoconf = ipv6_defaults.autoconf; | |
49 | - dflt->disable_ipv6 = ipv6_defaults.disable_ipv6; | |
50 | - } | |
51 | + /* these will be inherited by all namespaces */ | |
52 | + dflt->autoconf = ipv6_defaults.autoconf; | |
53 | + dflt->disable_ipv6 = ipv6_defaults.disable_ipv6; | |
54 | ||
55 | net->ipv6.devconf_all = all; | |
56 | net->ipv6.devconf_dflt = dflt; |