aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/nsproxy.c23
-rw-r--r--kernel/user_namespace.c6
-rw-r--r--kernel/utsname.c10
3 files changed, 26 insertions, 13 deletions
diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c
index 5aa28e219487..15a6015a849d 100644
--- a/kernel/nsproxy.c
+++ b/kernel/nsproxy.c
@@ -58,30 +58,41 @@ static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
58 struct fs_struct *new_fs) 58 struct fs_struct *new_fs)
59{ 59{
60 struct nsproxy *new_nsp; 60 struct nsproxy *new_nsp;
61 int err;
61 62
62 new_nsp = clone_nsproxy(tsk->nsproxy); 63 new_nsp = clone_nsproxy(tsk->nsproxy);
63 if (!new_nsp) 64 if (!new_nsp)
64 return ERR_PTR(-ENOMEM); 65 return ERR_PTR(-ENOMEM);
65 66
66 new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs); 67 new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
67 if (IS_ERR(new_nsp->mnt_ns)) 68 if (IS_ERR(new_nsp->mnt_ns)) {
69 err = PTR_ERR(new_nsp->mnt_ns);
68 goto out_ns; 70 goto out_ns;
71 }
69 72
70 new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns); 73 new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
71 if (IS_ERR(new_nsp->uts_ns)) 74 if (IS_ERR(new_nsp->uts_ns)) {
75 err = PTR_ERR(new_nsp->uts_ns);
72 goto out_uts; 76 goto out_uts;
77 }
73 78
74 new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns); 79 new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
75 if (IS_ERR(new_nsp->ipc_ns)) 80 if (IS_ERR(new_nsp->ipc_ns)) {
81 err = PTR_ERR(new_nsp->ipc_ns);
76 goto out_ipc; 82 goto out_ipc;
83 }
77 84
78 new_nsp->pid_ns = copy_pid_ns(flags, tsk->nsproxy->pid_ns); 85 new_nsp->pid_ns = copy_pid_ns(flags, tsk->nsproxy->pid_ns);
79 if (IS_ERR(new_nsp->pid_ns)) 86 if (IS_ERR(new_nsp->pid_ns)) {
87 err = PTR_ERR(new_nsp->pid_ns);
80 goto out_pid; 88 goto out_pid;
89 }
81 90
82 new_nsp->user_ns = copy_user_ns(flags, tsk->nsproxy->user_ns); 91 new_nsp->user_ns = copy_user_ns(flags, tsk->nsproxy->user_ns);
83 if (IS_ERR(new_nsp->user_ns)) 92 if (IS_ERR(new_nsp->user_ns)) {
93 err = PTR_ERR(new_nsp->user_ns);
84 goto out_user; 94 goto out_user;
95 }
85 96
86 return new_nsp; 97 return new_nsp;
87 98
@@ -99,7 +110,7 @@ out_uts:
99 put_mnt_ns(new_nsp->mnt_ns); 110 put_mnt_ns(new_nsp->mnt_ns);
100out_ns: 111out_ns:
101 kfree(new_nsp); 112 kfree(new_nsp);
102 return ERR_PTR(-ENOMEM); 113 return ERR_PTR(err);
103} 114}
104 115
105/* 116/*
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
index 89a27e8b17fb..d055d987850c 100644
--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -34,7 +34,7 @@ static struct user_namespace *clone_user_ns(struct user_namespace *old_ns)
34 34
35 ns = kmalloc(sizeof(struct user_namespace), GFP_KERNEL); 35 ns = kmalloc(sizeof(struct user_namespace), GFP_KERNEL);
36 if (!ns) 36 if (!ns)
37 return NULL; 37 return ERR_PTR(-ENOMEM);
38 38
39 kref_init(&ns->kref); 39 kref_init(&ns->kref);
40 40
@@ -45,7 +45,7 @@ static struct user_namespace *clone_user_ns(struct user_namespace *old_ns)
45 ns->root_user = alloc_uid(ns, 0); 45 ns->root_user = alloc_uid(ns, 0);
46 if (!ns->root_user) { 46 if (!ns->root_user) {
47 kfree(ns); 47 kfree(ns);
48 return NULL; 48 return ERR_PTR(-ENOMEM);
49 } 49 }
50 50
51 /* Reset current->user with a new one */ 51 /* Reset current->user with a new one */
@@ -53,7 +53,7 @@ static struct user_namespace *clone_user_ns(struct user_namespace *old_ns)
53 if (!new_user) { 53 if (!new_user) {
54 free_uid(ns->root_user); 54 free_uid(ns->root_user);
55 kfree(ns); 55 kfree(ns);
56 return NULL; 56 return ERR_PTR(-ENOMEM);
57 } 57 }
58 58
59 switch_uid(new_user); 59 switch_uid(new_user);
diff --git a/kernel/utsname.c b/kernel/utsname.c
index 160c8c5136bd..3ae43936bd88 100644
--- a/kernel/utsname.c
+++ b/kernel/utsname.c
@@ -13,6 +13,7 @@
13#include <linux/uts.h> 13#include <linux/uts.h>
14#include <linux/utsname.h> 14#include <linux/utsname.h>
15#include <linux/version.h> 15#include <linux/version.h>
16#include <linux/err.h>
16 17
17/* 18/*
18 * Clone a new ns copying an original utsname, setting refcount to 1 19 * Clone a new ns copying an original utsname, setting refcount to 1
@@ -24,10 +25,11 @@ static struct uts_namespace *clone_uts_ns(struct uts_namespace *old_ns)
24 struct uts_namespace *ns; 25 struct uts_namespace *ns;
25 26
26 ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL); 27 ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
27 if (ns) { 28 if (!ns)
28 memcpy(&ns->name, &old_ns->name, sizeof(ns->name)); 29 return ERR_PTR(-ENOMEM);
29 kref_init(&ns->kref); 30
30 } 31 memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
32 kref_init(&ns->kref);
31 return ns; 33 return ns;
32} 34}
33 35