mirror of
https://git.yoctoproject.org/meta-ti
synced 2026-07-16 22:38:04 +00:00
2177f80076
Duplicate patches between PSP and 3.2.17 have been dropped from the 3.2.17 series Signed-off-by: Koen Kooi <koen@dominion.thruhere.net> Signed-off-by: Denys Dmytriyenko <denys@ti.com>
80 lines
2.0 KiB
Diff
80 lines
2.0 KiB
Diff
From 4637103c9e0f2f7cef243c369f6b451550a4944d Mon Sep 17 00:00:00 2001
|
|
From: Julian Anastasov <ja@ssi.bg>
|
|
Date: Mon, 16 Apr 2012 04:43:15 +0000
|
|
Subject: [PATCH 081/165] netns: do not leak net_generic data on failed init
|
|
|
|
[ Upstream commit b922934d017f1cc831b017913ed7d1a56c558b43 ]
|
|
|
|
ops_init should free the net_generic data on
|
|
init failure and __register_pernet_operations should not
|
|
call ops_free when NET_NS is not enabled.
|
|
|
|
Signed-off-by: Julian Anastasov <ja@ssi.bg>
|
|
Reviewed-by: "Eric W. Biederman" <ebiederm@xmission.com>
|
|
Signed-off-by: David S. Miller <davem@davemloft.net>
|
|
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
---
|
|
net/core/net_namespace.c | 33 ++++++++++++++++++---------------
|
|
1 files changed, 18 insertions(+), 15 deletions(-)
|
|
|
|
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
|
|
index 0e950fd..31a5ae5 100644
|
|
--- a/net/core/net_namespace.c
|
|
+++ b/net/core/net_namespace.c
|
|
@@ -83,21 +83,29 @@ assign:
|
|
|
|
static int ops_init(const struct pernet_operations *ops, struct net *net)
|
|
{
|
|
- int err;
|
|
+ int err = -ENOMEM;
|
|
+ void *data = NULL;
|
|
+
|
|
if (ops->id && ops->size) {
|
|
- void *data = kzalloc(ops->size, GFP_KERNEL);
|
|
+ data = kzalloc(ops->size, GFP_KERNEL);
|
|
if (!data)
|
|
- return -ENOMEM;
|
|
+ goto out;
|
|
|
|
err = net_assign_generic(net, *ops->id, data);
|
|
- if (err) {
|
|
- kfree(data);
|
|
- return err;
|
|
- }
|
|
+ if (err)
|
|
+ goto cleanup;
|
|
}
|
|
+ err = 0;
|
|
if (ops->init)
|
|
- return ops->init(net);
|
|
- return 0;
|
|
+ err = ops->init(net);
|
|
+ if (!err)
|
|
+ return 0;
|
|
+
|
|
+cleanup:
|
|
+ kfree(data);
|
|
+
|
|
+out:
|
|
+ return err;
|
|
}
|
|
|
|
static void ops_free(const struct pernet_operations *ops, struct net *net)
|
|
@@ -448,12 +456,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
|
|
static int __register_pernet_operations(struct list_head *list,
|
|
struct pernet_operations *ops)
|
|
{
|
|
- int err = 0;
|
|
- err = ops_init(ops, &init_net);
|
|
- if (err)
|
|
- ops_free(ops, &init_net);
|
|
- return err;
|
|
-
|
|
+ return ops_init(ops, &init_net);
|
|
}
|
|
|
|
static void __unregister_pernet_operations(struct pernet_operations *ops)
|
|
--
|
|
1.7.7.6
|
|
|