lkml.org 
[lkml]   [2011]   [Oct]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] kernel/nsproxy.c: Fix memory leak of create_new_namespaces().
copy_pid_ns() has allocted some memory via create_pid_namespace(), if copy_net_ns()
failed via create_new_namespaces(), it will cause memory leak. The copy_utsname()
have the same problem.

Signed-off-by: Zhitong Wang <zhitong.wangzt@alibaba-inc.com>

---
kernel/nsproxy.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c
index 9aeab4b..fdcec31 100644
--- a/kernel/nsproxy.c
+++ b/kernel/nsproxy.c
@@ -99,14 +99,18 @@ static struct nsproxy *create_new_namespaces(unsigned long flags,
return new_nsp;

out_net:
- if (new_nsp->pid_ns)
+ if (new_nsp->pid_ns) {
put_pid_ns(new_nsp->pid_ns);
+ free_pid_ns(&new_nsp->pid_ns->kref);
+ }
out_pid:
if (new_nsp->ipc_ns)
put_ipc_ns(new_nsp->ipc_ns);
out_ipc:
- if (new_nsp->uts_ns)
+ if (new_nsp->uts_ns) {
put_uts_ns(new_nsp->uts_ns);
+ free_uts_ns(&new_nsp->pid_ns->kref);
+ }
out_uts:
if (new_nsp->mnt_ns)
put_mnt_ns(new_nsp->mnt_ns);
--
1.7.4.1


\
 
 \ /
  Last update: 2011-10-18 08:11    [from the cache]
©2003-2011 Jasper Spaans