summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fs/namespace.c4
-rw-r--r--include/linux/ns_common.h3
-rw-r--r--include/linux/proc_ns.h2
-rw-r--r--ipc/namespace.c4
-rw-r--r--kernel/cgroup/namespace.c2
-rw-r--r--kernel/nscommon.c5
-rw-r--r--kernel/pid_namespace.c4
-rw-r--r--kernel/time/namespace.c2
-rw-r--r--kernel/user_namespace.c4
-rw-r--r--kernel/utsname.c2
-rw-r--r--net/core/net_namespace.c4
11 files changed, 21 insertions, 15 deletions
diff --git a/fs/namespace.c b/fs/namespace.c
index 699b8c770c47..b9f94769ec11 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -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);
diff --git a/include/linux/ns_common.h b/include/linux/ns_common.h
index 05c7a7dd211b..19833ac547f9 100644
--- a/include/linux/ns_common.h
+++ b/include/linux/ns_common.h
@@ -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
diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
index 9f21670b5824..08016f6e0e6f 100644
--- a/include/linux/proc_ns.h
+++ b/include/linux/proc_ns.h
@@ -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 */
diff --git a/ipc/namespace.c b/ipc/namespace.c
index 0f8bbd18a475..09d261a1a2aa 100644
--- a/ipc/namespace.c
+++ b/ipc/namespace.c
@@ -97,7 +97,7 @@ fail_mq:
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);
}
diff --git a/kernel/cgroup/namespace.c b/kernel/cgroup/namespace.c
index d928c557e28b..16ead7508371 100644
--- a/kernel/cgroup/namespace.c
+++ b/kernel/cgroup/namespace.c
@@ -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);
}
diff --git a/kernel/nscommon.c b/kernel/nscommon.c
index c3a90bb665ad..7c1b07e2a6c9 100644
--- a/kernel/nscommon.c
+++ b/kernel/nscommon.c
@@ -18,3 +18,8 @@ int __ns_common_init(struct ns_common *ns, const struct proc_ns_operations *ops,
}
return proc_alloc_inum(&ns->inum);
}
+
+void __ns_common_free(struct ns_common *ns)
+{
+ proc_free_inum(ns->inum);
+}
diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
index 170757c265c2..27e2dd9ee051 100644
--- a/kernel/pid_namespace.c
+++ b/kernel/pid_namespace.c
@@ -127,7 +127,7 @@ static struct pid_namespace *create_pid_namespace(struct user_namespace *user_ns
return ns;
out_free_inum:
- ns_free_inum(&ns->ns);
+ ns_common_free(ns);
out_free_idr:
idr_destroy(&ns->idr);
kmem_cache_free(pid_ns_cachep, ns);
@@ -152,7 +152,7 @@ static void destroy_pid_namespace(struct pid_namespace *ns)
ns_tree_remove(ns);
unregister_pidns_sysctls(ns);
- ns_free_inum(&ns->ns);
+ ns_common_free(ns);
idr_destroy(&ns->idr);
call_rcu(&ns->rcu, delayed_free_pidns);
diff --git a/kernel/time/namespace.c b/kernel/time/namespace.c
index ce8e952104a7..d49c73015d6e 100644
--- a/kernel/time/namespace.c
+++ b/kernel/time/namespace.c
@@ -255,7 +255,7 @@ void free_time_ns(struct time_namespace *ns)
ns_tree_remove(ns);
dec_time_namespaces(ns->ucounts);
put_user_ns(ns->user_ns);
- ns_free_inum(&ns->ns);
+ ns_common_free(ns);
__free_page(ns->vvar_page);
/* Concurrent nstree traversal depends on a grace period. */
kfree_rcu(ns, ns.ns_rcu);
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
index db9f0463219c..32406bcab526 100644
--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -165,7 +165,7 @@ fail_keyring:
#ifdef CONFIG_PERSISTENT_KEYRINGS
key_put(ns->persistent_keyring_register);
#endif
- ns_free_inum(&ns->ns);
+ ns_common_free(ns);
fail_free:
kmem_cache_free(user_ns_cachep, ns);
fail_dec:
@@ -220,7 +220,7 @@ static void free_user_ns(struct work_struct *work)
#endif
retire_userns_sysctls(ns);
key_free_user_ns(ns);
- ns_free_inum(&ns->ns);
+ ns_common_free(ns);
/* Concurrent nstree traversal depends on a grace period. */
kfree_rcu(ns, ns.ns_rcu);
dec_user_namespaces(ucounts);
diff --git a/kernel/utsname.c b/kernel/utsname.c
index 399888be66bd..95d733eb2c98 100644
--- a/kernel/utsname.c
+++ b/kernel/utsname.c
@@ -98,7 +98,7 @@ void free_uts_ns(struct uts_namespace *ns)
ns_tree_remove(ns);
dec_uts_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);
}
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index e50897fba8cd..a6a3de56a81c 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -590,7 +590,7 @@ struct net *copy_net_ns(unsigned long flags,
if (rv < 0) {
put_userns:
- ns_free_inum(&net->ns);
+ ns_common_free(net);
#ifdef CONFIG_KEYS
key_remove_domain(net->key_domain);
#endif
@@ -713,7 +713,7 @@ static void cleanup_net(struct work_struct *work)
/* Finally it is safe to free my network namespace structure */
list_for_each_entry_safe(net, tmp, &net_exit_list, exit_list) {
list_del_init(&net->exit_list);
- ns_free_inum(&net->ns);
+ ns_common_free(net);
dec_net_namespaces(net->ucounts);
#ifdef CONFIG_KEYS
key_remove_domain(net->key_domain);