On 10/05, Andrew Vagin wrote: > > Here is a stack trace of recursion: > free_pid_ns(parent) > put_pid_ns(parent) > kref_put(&ns->kref, free_pid_ns); > free_pid_ns > > This patch turns recursion into loops.
I think the patch is correct, a couple of minor nits. > +static inline int __kref_put(struct kref *kref) > +{ > + return atomic_sub_and_test(1, &kref->refcount); perhaps atomic_dec_and_test(&kref->refcount) makes more sense? > +} > @@ -138,11 +138,20 @@ void free_pid_ns(struct kref *kref) > > ns = container_of(kref, struct pid_namespace, kref); > > - parent = ns->parent; > - destroy_pid_namespace(ns); > + while (1) { > > - if (parent != NULL) > - put_pid_ns(parent); > + parent = ns->parent; > + destroy_pid_namespace(ns); > + > + if (parent == NULL || parent == &init_pid_ns) ^^^^^^^^^^^^^^ Why ns->parent == NULL is only possible if ns == init_pid_ns, right? But in this case we should not be here. The caller verifies that initial ns != init_pid_ns, and this loops should stop once we reach init_pid_ns. Oleg. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/