diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2014-11-01 00:45:45 -0400 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-12-04 14:34:36 -0500 |
| commit | 6344c433a452b1a05d03a61a6a85d89f793bb7b8 (patch) | |
| tree | d7fb4505dc394206c1b98bb02dfc58cce16dfe7c | |
| parent | 64964528b24ea390824f0e5ce9d34b8d39b28cde (diff) | |
new helpers: ns_alloc_inum/ns_free_inum
take struct ns_common *, for now simply wrappers around proc_{alloc,free}_inum()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
| -rw-r--r-- | fs/namespace.c | 4 | ||||
| -rw-r--r-- | include/linux/proc_ns.h | 3 | ||||
| -rw-r--r-- | ipc/namespace.c | 6 | ||||
| -rw-r--r-- | kernel/pid_namespace.c | 4 | ||||
| -rw-r--r-- | kernel/user_namespace.c | 4 | ||||
| -rw-r--r-- | kernel/utsname.c | 4 | ||||
| -rw-r--r-- | net/core/net_namespace.c | 4 |
7 files changed, 16 insertions, 13 deletions
diff --git a/fs/namespace.c b/fs/namespace.c index b9c16c3f63f5..30738d200866 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
| @@ -2645,7 +2645,7 @@ dput_out: | |||
| 2645 | 2645 | ||
| 2646 | static void free_mnt_ns(struct mnt_namespace *ns) | 2646 | static void free_mnt_ns(struct mnt_namespace *ns) |
| 2647 | { | 2647 | { |
| 2648 | proc_free_inum(ns->ns.inum); | 2648 | ns_free_inum(&ns->ns); |
| 2649 | put_user_ns(ns->user_ns); | 2649 | put_user_ns(ns->user_ns); |
| 2650 | kfree(ns); | 2650 | kfree(ns); |
| 2651 | } | 2651 | } |
| @@ -2667,7 +2667,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns) | |||
| 2667 | new_ns = kmalloc(sizeof(struct mnt_namespace), GFP_KERNEL); | 2667 | new_ns = kmalloc(sizeof(struct mnt_namespace), GFP_KERNEL); |
| 2668 | if (!new_ns) | 2668 | if (!new_ns) |
| 2669 | return ERR_PTR(-ENOMEM); | 2669 | return ERR_PTR(-ENOMEM); |
| 2670 | ret = proc_alloc_inum(&new_ns->ns.inum); | 2670 | ret = ns_alloc_inum(&new_ns->ns); |
| 2671 | if (ret) { | 2671 | if (ret) { |
| 2672 | kfree(new_ns); | 2672 | kfree(new_ns); |
| 2673 | return ERR_PTR(ret); | 2673 | return ERR_PTR(ret); |
diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h index f284959391fd..f5780ee7f8f7 100644 --- a/include/linux/proc_ns.h +++ b/include/linux/proc_ns.h | |||
| @@ -71,4 +71,7 @@ static inline bool proc_ns_inode(struct inode *inode) { return false; } | |||
| 71 | 71 | ||
| 72 | #endif /* CONFIG_PROC_FS */ | 72 | #endif /* CONFIG_PROC_FS */ |
| 73 | 73 | ||
| 74 | #define ns_alloc_inum(ns) proc_alloc_inum(&(ns)->inum) | ||
| 75 | #define ns_free_inum(ns) proc_free_inum((ns)->inum) | ||
| 76 | |||
| 74 | #endif /* _LINUX_PROC_NS_H */ | 77 | #endif /* _LINUX_PROC_NS_H */ |
diff --git a/ipc/namespace.c b/ipc/namespace.c index 531029a67fef..bcdd7a5c122a 100644 --- a/ipc/namespace.c +++ b/ipc/namespace.c | |||
| @@ -26,7 +26,7 @@ static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns, | |||
| 26 | if (ns == NULL) | 26 | if (ns == NULL) |
| 27 | return ERR_PTR(-ENOMEM); | 27 | return ERR_PTR(-ENOMEM); |
| 28 | 28 | ||
| 29 | err = proc_alloc_inum(&ns->ns.inum); | 29 | err = ns_alloc_inum(&ns->ns); |
| 30 | if (err) { | 30 | if (err) { |
| 31 | kfree(ns); | 31 | kfree(ns); |
| 32 | return ERR_PTR(err); | 32 | return ERR_PTR(err); |
| @@ -35,7 +35,7 @@ static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns, | |||
| 35 | atomic_set(&ns->count, 1); | 35 | atomic_set(&ns->count, 1); |
| 36 | err = mq_init_ns(ns); | 36 | err = mq_init_ns(ns); |
| 37 | if (err) { | 37 | if (err) { |
| 38 | proc_free_inum(ns->ns.inum); | 38 | ns_free_inum(&ns->ns); |
| 39 | kfree(ns); | 39 | kfree(ns); |
| 40 | return ERR_PTR(err); | 40 | return ERR_PTR(err); |
| 41 | } | 41 | } |
| @@ -119,7 +119,7 @@ static void free_ipc_ns(struct ipc_namespace *ns) | |||
| 119 | */ | 119 | */ |
| 120 | ipcns_notify(IPCNS_REMOVED); | 120 | ipcns_notify(IPCNS_REMOVED); |
| 121 | put_user_ns(ns->user_ns); | 121 | put_user_ns(ns->user_ns); |
| 122 | proc_free_inum(ns->ns.inum); | 122 | ns_free_inum(&ns->ns); |
| 123 | kfree(ns); | 123 | kfree(ns); |
| 124 | } | 124 | } |
| 125 | 125 | ||
diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c index 79aabce49a85..5aa9158a84d5 100644 --- a/kernel/pid_namespace.c +++ b/kernel/pid_namespace.c | |||
| @@ -105,7 +105,7 @@ static struct pid_namespace *create_pid_namespace(struct user_namespace *user_ns | |||
| 105 | if (ns->pid_cachep == NULL) | 105 | if (ns->pid_cachep == NULL) |
| 106 | goto out_free_map; | 106 | goto out_free_map; |
| 107 | 107 | ||
| 108 | err = proc_alloc_inum(&ns->ns.inum); | 108 | err = ns_alloc_inum(&ns->ns); |
| 109 | if (err) | 109 | if (err) |
| 110 | goto out_free_map; | 110 | goto out_free_map; |
| 111 | 111 | ||
| @@ -142,7 +142,7 @@ static void destroy_pid_namespace(struct pid_namespace *ns) | |||
| 142 | { | 142 | { |
| 143 | int i; | 143 | int i; |
| 144 | 144 | ||
| 145 | proc_free_inum(ns->ns.inum); | 145 | ns_free_inum(&ns->ns); |
| 146 | for (i = 0; i < PIDMAP_ENTRIES; i++) | 146 | for (i = 0; i < PIDMAP_ENTRIES; i++) |
| 147 | kfree(ns->pidmap[i].page); | 147 | kfree(ns->pidmap[i].page); |
| 148 | put_user_ns(ns->user_ns); | 148 | put_user_ns(ns->user_ns); |
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c index 29cd5ccfc37a..6bf8177768e5 100644 --- a/kernel/user_namespace.c +++ b/kernel/user_namespace.c | |||
| @@ -86,7 +86,7 @@ int create_user_ns(struct cred *new) | |||
| 86 | if (!ns) | 86 | if (!ns) |
| 87 | return -ENOMEM; | 87 | return -ENOMEM; |
| 88 | 88 | ||
| 89 | ret = proc_alloc_inum(&ns->ns.inum); | 89 | ret = ns_alloc_inum(&ns->ns); |
| 90 | if (ret) { | 90 | if (ret) { |
| 91 | kmem_cache_free(user_ns_cachep, ns); | 91 | kmem_cache_free(user_ns_cachep, ns); |
| 92 | return ret; | 92 | return ret; |
| @@ -136,7 +136,7 @@ void free_user_ns(struct user_namespace *ns) | |||
| 136 | #ifdef CONFIG_PERSISTENT_KEYRINGS | 136 | #ifdef CONFIG_PERSISTENT_KEYRINGS |
| 137 | key_put(ns->persistent_keyring_register); | 137 | key_put(ns->persistent_keyring_register); |
| 138 | #endif | 138 | #endif |
| 139 | proc_free_inum(ns->ns.inum); | 139 | ns_free_inum(&ns->ns); |
| 140 | kmem_cache_free(user_ns_cachep, ns); | 140 | kmem_cache_free(user_ns_cachep, ns); |
| 141 | ns = parent; | 141 | ns = parent; |
| 142 | } while (atomic_dec_and_test(&parent->count)); | 142 | } while (atomic_dec_and_test(&parent->count)); |
diff --git a/kernel/utsname.c b/kernel/utsname.c index 20697befe466..c2a2b321d88a 100644 --- a/kernel/utsname.c +++ b/kernel/utsname.c | |||
| @@ -42,7 +42,7 @@ static struct uts_namespace *clone_uts_ns(struct user_namespace *user_ns, | |||
| 42 | if (!ns) | 42 | if (!ns) |
| 43 | return ERR_PTR(-ENOMEM); | 43 | return ERR_PTR(-ENOMEM); |
| 44 | 44 | ||
| 45 | err = proc_alloc_inum(&ns->ns.inum); | 45 | err = ns_alloc_inum(&ns->ns); |
| 46 | if (err) { | 46 | if (err) { |
| 47 | kfree(ns); | 47 | kfree(ns); |
| 48 | return ERR_PTR(err); | 48 | return ERR_PTR(err); |
| @@ -84,7 +84,7 @@ void free_uts_ns(struct kref *kref) | |||
| 84 | 84 | ||
| 85 | ns = container_of(kref, struct uts_namespace, kref); | 85 | ns = container_of(kref, struct uts_namespace, kref); |
| 86 | put_user_ns(ns->user_ns); | 86 | put_user_ns(ns->user_ns); |
| 87 | proc_free_inum(ns->ns.inum); | 87 | ns_free_inum(&ns->ns); |
| 88 | kfree(ns); | 88 | kfree(ns); |
| 89 | } | 89 | } |
| 90 | 90 | ||
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c index 2161f0979fce..da775f53f3fd 100644 --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c | |||
| @@ -386,12 +386,12 @@ EXPORT_SYMBOL_GPL(get_net_ns_by_pid); | |||
| 386 | 386 | ||
| 387 | static __net_init int net_ns_net_init(struct net *net) | 387 | static __net_init int net_ns_net_init(struct net *net) |
| 388 | { | 388 | { |
| 389 | return proc_alloc_inum(&net->ns.inum); | 389 | return ns_alloc_inum(&net->ns); |
| 390 | } | 390 | } |
| 391 | 391 | ||
| 392 | static __net_exit void net_ns_net_exit(struct net *net) | 392 | static __net_exit void net_ns_net_exit(struct net *net) |
| 393 | { | 393 | { |
| 394 | proc_free_inum(net->ns.inum); | 394 | ns_free_inum(&net->ns); |
| 395 | } | 395 | } |
| 396 | 396 | ||
| 397 | static struct pernet_operations __net_initdata net_ns_ops = { | 397 | static struct pernet_operations __net_initdata net_ns_ops = { |
