Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6344c433 authored by Al Viro's avatar Al Viro
Browse files

new helpers: ns_alloc_inum/ns_free_inum



take struct ns_common *, for now simply wrappers around proc_{alloc,free}_inum()

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 64964528
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -2645,7 +2645,7 @@ dput_out:


static void free_mnt_ns(struct mnt_namespace *ns)
static void free_mnt_ns(struct mnt_namespace *ns)
{
{
	proc_free_inum(ns->ns.inum);
	ns_free_inum(&ns->ns);
	put_user_ns(ns->user_ns);
	put_user_ns(ns->user_ns);
	kfree(ns);
	kfree(ns);
}
}
@@ -2667,7 +2667,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
	new_ns = kmalloc(sizeof(struct mnt_namespace), GFP_KERNEL);
	new_ns = kmalloc(sizeof(struct mnt_namespace), GFP_KERNEL);
	if (!new_ns)
	if (!new_ns)
		return ERR_PTR(-ENOMEM);
		return ERR_PTR(-ENOMEM);
	ret = proc_alloc_inum(&new_ns->ns.inum);
	ret = ns_alloc_inum(&new_ns->ns);
	if (ret) {
	if (ret) {
		kfree(new_ns);
		kfree(new_ns);
		return ERR_PTR(ret);
		return ERR_PTR(ret);
+3 −0
Original line number Original line Diff line number Diff line
@@ -71,4 +71,7 @@ static inline bool proc_ns_inode(struct inode *inode) { return false; }


#endif /* CONFIG_PROC_FS */
#endif /* CONFIG_PROC_FS */


#define ns_alloc_inum(ns) proc_alloc_inum(&(ns)->inum)
#define ns_free_inum(ns) proc_free_inum((ns)->inum)

#endif /* _LINUX_PROC_NS_H */
#endif /* _LINUX_PROC_NS_H */
+3 −3
Original line number Original line Diff line number Diff line
@@ -26,7 +26,7 @@ static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns,
	if (ns == NULL)
	if (ns == NULL)
		return ERR_PTR(-ENOMEM);
		return ERR_PTR(-ENOMEM);


	err = proc_alloc_inum(&ns->ns.inum);
	err = ns_alloc_inum(&ns->ns);
	if (err) {
	if (err) {
		kfree(ns);
		kfree(ns);
		return ERR_PTR(err);
		return ERR_PTR(err);
@@ -35,7 +35,7 @@ static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns,
	atomic_set(&ns->count, 1);
	atomic_set(&ns->count, 1);
	err = mq_init_ns(ns);
	err = mq_init_ns(ns);
	if (err) {
	if (err) {
		proc_free_inum(ns->ns.inum);
		ns_free_inum(&ns->ns);
		kfree(ns);
		kfree(ns);
		return ERR_PTR(err);
		return ERR_PTR(err);
	}
	}
@@ -119,7 +119,7 @@ static void free_ipc_ns(struct ipc_namespace *ns)
	 */
	 */
	ipcns_notify(IPCNS_REMOVED);
	ipcns_notify(IPCNS_REMOVED);
	put_user_ns(ns->user_ns);
	put_user_ns(ns->user_ns);
	proc_free_inum(ns->ns.inum);
	ns_free_inum(&ns->ns);
	kfree(ns);
	kfree(ns);
}
}


+2 −2
Original line number Original line Diff line number Diff line
@@ -105,7 +105,7 @@ static struct pid_namespace *create_pid_namespace(struct user_namespace *user_ns
	if (ns->pid_cachep == NULL)
	if (ns->pid_cachep == NULL)
		goto out_free_map;
		goto out_free_map;


	err = proc_alloc_inum(&ns->ns.inum);
	err = ns_alloc_inum(&ns->ns);
	if (err)
	if (err)
		goto out_free_map;
		goto out_free_map;


@@ -142,7 +142,7 @@ static void destroy_pid_namespace(struct pid_namespace *ns)
{
{
	int i;
	int i;


	proc_free_inum(ns->ns.inum);
	ns_free_inum(&ns->ns);
	for (i = 0; i < PIDMAP_ENTRIES; i++)
	for (i = 0; i < PIDMAP_ENTRIES; i++)
		kfree(ns->pidmap[i].page);
		kfree(ns->pidmap[i].page);
	put_user_ns(ns->user_ns);
	put_user_ns(ns->user_ns);
+2 −2
Original line number Original line Diff line number Diff line
@@ -86,7 +86,7 @@ int create_user_ns(struct cred *new)
	if (!ns)
	if (!ns)
		return -ENOMEM;
		return -ENOMEM;


	ret = proc_alloc_inum(&ns->ns.inum);
	ret = ns_alloc_inum(&ns->ns);
	if (ret) {
	if (ret) {
		kmem_cache_free(user_ns_cachep, ns);
		kmem_cache_free(user_ns_cachep, ns);
		return ret;
		return ret;
@@ -136,7 +136,7 @@ void free_user_ns(struct user_namespace *ns)
#ifdef CONFIG_PERSISTENT_KEYRINGS
#ifdef CONFIG_PERSISTENT_KEYRINGS
		key_put(ns->persistent_keyring_register);
		key_put(ns->persistent_keyring_register);
#endif
#endif
		proc_free_inum(ns->ns.inum);
		ns_free_inum(&ns->ns);
		kmem_cache_free(user_ns_cachep, ns);
		kmem_cache_free(user_ns_cachep, ns);
		ns = parent;
		ns = parent;
	} while (atomic_dec_and_test(&parent->count));
	} while (atomic_dec_and_test(&parent->count));
Loading