Unverified Commit be5f21d3 authored by Christian Brauner's avatar Christian Brauner
Browse files

ns: add ns_common_free()



And drop ns_free_inum(). Anything common that can be wasted centrally
should be wasted in the new common helper.

Reviewed-by: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent 5612ff3e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -4082,7 +4082,7 @@ static void dec_mnt_namespaces(struct ucounts *ucounts)
static void free_mnt_ns(struct mnt_namespace *ns)
{
	if (!is_anon_ns(ns))
		ns_free_inum(&ns->ns);
		ns_common_free(ns);
	dec_mnt_namespaces(ns->ucounts);
	mnt_ns_tree_remove(ns);
}
@@ -4154,7 +4154,7 @@ struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns,
	new = copy_tree(old, old->mnt.mnt_root, copy_flags);
	if (IS_ERR(new)) {
		namespace_unlock();
		ns_free_inum(&new_ns->ns);
		ns_common_free(ns);
		dec_mnt_namespaces(new_ns->ucounts);
		mnt_ns_release(new_ns);
		return ERR_CAST(new);
+3 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ struct ns_common {
};

int __ns_common_init(struct ns_common *ns, const struct proc_ns_operations *ops, int inum);
void __ns_common_free(struct ns_common *ns);

#define to_ns_common(__ns)                              \
	_Generic((__ns),                                \
@@ -80,4 +81,6 @@ int __ns_common_init(struct ns_common *ns, const struct proc_ns_operations *ops,

#define ns_common_init_inum(__ns, __ops, __inum) __ns_common_init(to_ns_common(__ns), __ops, __inum)

#define ns_common_free(__ns) __ns_common_free(to_ns_common((__ns)))

#endif
+0 −2
Original line number Diff line number Diff line
@@ -66,8 +66,6 @@ static inline void proc_free_inum(unsigned int inum) {}

#endif /* CONFIG_PROC_FS */

#define ns_free_inum(ns) proc_free_inum((ns)->inum)

#define get_proc_ns(inode) ((struct ns_common *)(inode)->i_private)

#endif /* _LINUX_PROC_NS_H */
+2 −2
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns,

fail_put:
	put_user_ns(ns->user_ns);
	ns_free_inum(&ns->ns);
	ns_common_free(ns);
fail_free:
	kfree(ns);
fail_dec:
@@ -161,7 +161,7 @@ static void free_ipc_ns(struct ipc_namespace *ns)

	dec_ipc_namespaces(ns->ucounts);
	put_user_ns(ns->user_ns);
	ns_free_inum(&ns->ns);
	ns_common_free(ns);
	kfree(ns);
}

+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ void free_cgroup_ns(struct cgroup_namespace *ns)
	put_css_set(ns->root_cset);
	dec_cgroup_namespaces(ns->ucounts);
	put_user_ns(ns->user_ns);
	ns_free_inum(&ns->ns);
	ns_common_free(ns);
	/* Concurrent nstree traversal depends on a grace period. */
	kfree_rcu(ns, ns.ns_rcu);
}
Loading