diff options
Diffstat (limited to 'recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.17/0081-netns-do-not-leak-net_generic-data-on-failed-init.patch')
-rw-r--r-- | recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.17/0081-netns-do-not-leak-net_generic-data-on-failed-init.patch | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.17/0081-netns-do-not-leak-net_generic-data-on-failed-init.patch b/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.17/0081-netns-do-not-leak-net_generic-data-on-failed-init.patch new file mode 100644 index 00000000..b5c686d2 --- /dev/null +++ b/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.17/0081-netns-do-not-leak-net_generic-data-on-failed-init.patch | |||
@@ -0,0 +1,79 @@ | |||
1 | From 4637103c9e0f2f7cef243c369f6b451550a4944d Mon Sep 17 00:00:00 2001 | ||
2 | From: Julian Anastasov <ja@ssi.bg> | ||
3 | Date: Mon, 16 Apr 2012 04:43:15 +0000 | ||
4 | Subject: [PATCH 081/165] netns: do not leak net_generic data on failed init | ||
5 | |||
6 | [ Upstream commit b922934d017f1cc831b017913ed7d1a56c558b43 ] | ||
7 | |||
8 | ops_init should free the net_generic data on | ||
9 | init failure and __register_pernet_operations should not | ||
10 | call ops_free when NET_NS is not enabled. | ||
11 | |||
12 | Signed-off-by: Julian Anastasov <ja@ssi.bg> | ||
13 | Reviewed-by: "Eric W. Biederman" <ebiederm@xmission.com> | ||
14 | Signed-off-by: David S. Miller <davem@davemloft.net> | ||
15 | Signed-off-by: Ben Hutchings <ben@decadent.org.uk> | ||
16 | --- | ||
17 | net/core/net_namespace.c | 33 ++++++++++++++++++--------------- | ||
18 | 1 files changed, 18 insertions(+), 15 deletions(-) | ||
19 | |||
20 | diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c | ||
21 | index 0e950fd..31a5ae5 100644 | ||
22 | --- a/net/core/net_namespace.c | ||
23 | +++ b/net/core/net_namespace.c | ||
24 | @@ -83,21 +83,29 @@ assign: | ||
25 | |||
26 | static int ops_init(const struct pernet_operations *ops, struct net *net) | ||
27 | { | ||
28 | - int err; | ||
29 | + int err = -ENOMEM; | ||
30 | + void *data = NULL; | ||
31 | + | ||
32 | if (ops->id && ops->size) { | ||
33 | - void *data = kzalloc(ops->size, GFP_KERNEL); | ||
34 | + data = kzalloc(ops->size, GFP_KERNEL); | ||
35 | if (!data) | ||
36 | - return -ENOMEM; | ||
37 | + goto out; | ||
38 | |||
39 | err = net_assign_generic(net, *ops->id, data); | ||
40 | - if (err) { | ||
41 | - kfree(data); | ||
42 | - return err; | ||
43 | - } | ||
44 | + if (err) | ||
45 | + goto cleanup; | ||
46 | } | ||
47 | + err = 0; | ||
48 | if (ops->init) | ||
49 | - return ops->init(net); | ||
50 | - return 0; | ||
51 | + err = ops->init(net); | ||
52 | + if (!err) | ||
53 | + return 0; | ||
54 | + | ||
55 | +cleanup: | ||
56 | + kfree(data); | ||
57 | + | ||
58 | +out: | ||
59 | + return err; | ||
60 | } | ||
61 | |||
62 | static void ops_free(const struct pernet_operations *ops, struct net *net) | ||
63 | @@ -448,12 +456,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops) | ||
64 | static int __register_pernet_operations(struct list_head *list, | ||
65 | struct pernet_operations *ops) | ||
66 | { | ||
67 | - int err = 0; | ||
68 | - err = ops_init(ops, &init_net); | ||
69 | - if (err) | ||
70 | - ops_free(ops, &init_net); | ||
71 | - return err; | ||
72 | - | ||
73 | + return ops_init(ops, &init_net); | ||
74 | } | ||
75 | |||
76 | static void __unregister_pernet_operations(struct pernet_operations *ops) | ||
77 | -- | ||
78 | 1.7.7.6 | ||
79 | |||