aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/namespace.c4
-rw-r--r--kernel/nsproxy.c23
-rw-r--r--kernel/user_namespace.c6
-rw-r--r--kernel/utsname.c10
4 files changed, 28 insertions, 15 deletions
diff --git a/fs/namespace.c b/fs/namespace.c
index c811a94e4c88..5585623f6252 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1451,7 +1451,7 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
1451 1451
1452 new_ns = kmalloc(sizeof(struct mnt_namespace), GFP_KERNEL); 1452 new_ns = kmalloc(sizeof(struct mnt_namespace), GFP_KERNEL);
1453 if (!new_ns) 1453 if (!new_ns)
1454 return NULL; 1454 return ERR_PTR(-ENOMEM);
1455 1455
1456 atomic_set(&new_ns->count, 1); 1456 atomic_set(&new_ns->count, 1);
1457 INIT_LIST_HEAD(&new_ns->list); 1457 INIT_LIST_HEAD(&new_ns->list);
@@ -1465,7 +1465,7 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
1465 if (!new_ns->root) { 1465 if (!new_ns->root) {
1466 up_write(&namespace_sem); 1466 up_write(&namespace_sem);
1467 kfree(new_ns); 1467 kfree(new_ns);
1468 return NULL; 1468 return ERR_PTR(-ENOMEM);;
1469 } 1469 }
1470 spin_lock(&vfsmount_lock); 1470 spin_lock(&vfsmount_lock);
1471 list_add_tail(&new_ns->list, &new_ns->root->mnt_list); 1471 list_add_tail(&new_ns->list, &new_ns->root->mnt_list);
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