aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/pid_namespace.h8
-rw-r--r--kernel/pid_namespace.c21
2 files changed, 15 insertions, 14 deletions
diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h
index 00474b047145..65e3e87eacc5 100644
--- a/include/linux/pid_namespace.h
+++ b/include/linux/pid_namespace.h
@@ -47,15 +47,9 @@ static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns)
47} 47}
48 48
49extern struct pid_namespace *copy_pid_ns(unsigned long flags, struct pid_namespace *ns); 49extern struct pid_namespace *copy_pid_ns(unsigned long flags, struct pid_namespace *ns);
50extern void free_pid_ns(struct kref *kref);
51extern void zap_pid_ns_processes(struct pid_namespace *pid_ns); 50extern void zap_pid_ns_processes(struct pid_namespace *pid_ns);
52extern int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd); 51extern int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd);
53 52extern void put_pid_ns(struct pid_namespace *ns);
54static inline void put_pid_ns(struct pid_namespace *ns)
55{
56 if (ns != &init_pid_ns)
57 kref_put(&ns->kref, free_pid_ns);
58}
59 53
60#else /* !CONFIG_PID_NS */ 54#else /* !CONFIG_PID_NS */
61#include <linux/err.h> 55#include <linux/err.h>
diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
index 478bad2745e3..eb00be205811 100644
--- a/kernel/pid_namespace.c
+++ b/kernel/pid_namespace.c
@@ -133,19 +133,26 @@ struct pid_namespace *copy_pid_ns(unsigned long flags, struct pid_namespace *old
133 return create_pid_namespace(old_ns); 133 return create_pid_namespace(old_ns);
134} 134}
135 135
136void free_pid_ns(struct kref *kref) 136static void free_pid_ns(struct kref *kref)
137{ 137{
138 struct pid_namespace *ns, *parent; 138 struct pid_namespace *ns;
139 139
140 ns = container_of(kref, struct pid_namespace, kref); 140 ns = container_of(kref, struct pid_namespace, kref);
141
142 parent = ns->parent;
143 destroy_pid_namespace(ns); 141 destroy_pid_namespace(ns);
142}
144 143
145 if (parent != NULL) 144void put_pid_ns(struct pid_namespace *ns)
146 put_pid_ns(parent); 145{
146 struct pid_namespace *parent;
147
148 while (ns != &init_pid_ns) {
149 parent = ns->parent;
150 if (!kref_put(&ns->kref, free_pid_ns))
151 break;
152 ns = parent;
153 }
147} 154}
148EXPORT_SYMBOL_GPL(free_pid_ns); 155EXPORT_SYMBOL_GPL(put_pid_ns);
149 156
150void zap_pid_ns_processes(struct pid_namespace *pid_ns) 157void zap_pid_ns_processes(struct pid_namespace *pid_ns)
151{ 158{