From dad9d215b1a147ed423da50f87990f1d4e545641 Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Fri, 19 Oct 2012 13:56:53 -0700 Subject: [PATCH] --- yaml --- r: 334596 b: refs/heads/master c: bbc2e3ef87851bc5430b2b4cf4ca3a2f29baeda6 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/include/linux/pid_namespace.h | 8 +------- trunk/kernel/pid_namespace.c | 21 ++++++++++++++------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/[refs] b/[refs] index ff605c3d5fbb..005701ec3e8b 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: dc36d7e7cd422d69b15e7ec7cc1f021f581a6b6d +refs/heads/master: bbc2e3ef87851bc5430b2b4cf4ca3a2f29baeda6 diff --git a/trunk/include/linux/pid_namespace.h b/trunk/include/linux/pid_namespace.h index 00474b047145..65e3e87eacc5 100644 --- a/trunk/include/linux/pid_namespace.h +++ b/trunk/include/linux/pid_namespace.h @@ -47,15 +47,9 @@ static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns) } extern struct pid_namespace *copy_pid_ns(unsigned long flags, struct pid_namespace *ns); -extern void free_pid_ns(struct kref *kref); extern void zap_pid_ns_processes(struct pid_namespace *pid_ns); extern int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd); - -static inline void put_pid_ns(struct pid_namespace *ns) -{ - if (ns != &init_pid_ns) - kref_put(&ns->kref, free_pid_ns); -} +extern void put_pid_ns(struct pid_namespace *ns); #else /* !CONFIG_PID_NS */ #include diff --git a/trunk/kernel/pid_namespace.c b/trunk/kernel/pid_namespace.c index 478bad2745e3..eb00be205811 100644 --- a/trunk/kernel/pid_namespace.c +++ b/trunk/kernel/pid_namespace.c @@ -133,19 +133,26 @@ struct pid_namespace *copy_pid_ns(unsigned long flags, struct pid_namespace *old return create_pid_namespace(old_ns); } -void free_pid_ns(struct kref *kref) +static void free_pid_ns(struct kref *kref) { - struct pid_namespace *ns, *parent; + struct pid_namespace *ns; ns = container_of(kref, struct pid_namespace, kref); - - parent = ns->parent; destroy_pid_namespace(ns); +} - if (parent != NULL) - put_pid_ns(parent); +void put_pid_ns(struct pid_namespace *ns) +{ + struct pid_namespace *parent; + + while (ns != &init_pid_ns) { + parent = ns->parent; + if (!kref_put(&ns->kref, free_pid_ns)) + break; + ns = parent; + } } -EXPORT_SYMBOL_GPL(free_pid_ns); +EXPORT_SYMBOL_GPL(put_pid_ns); void zap_pid_ns_processes(struct pid_namespace *pid_ns) {