utsname.c (ead5d1f4d877e92c051e1a1ade623d0d30e71619) utsname.c (9a56493f6942c0e2df1579986128721da96e00d8)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (C) 2004 IBM Corporation
4 *
5 * Author: Serge Hallyn <serue@us.ibm.com>
6 */
7
8#include <linux/export.h>

--- 19 unchanged lines hidden (view full) ---

28}
29
30static struct uts_namespace *create_uts_ns(void)
31{
32 struct uts_namespace *uts_ns;
33
34 uts_ns = kmem_cache_alloc(uts_ns_cache, GFP_KERNEL);
35 if (uts_ns)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (C) 2004 IBM Corporation
4 *
5 * Author: Serge Hallyn <serue@us.ibm.com>
6 */
7
8#include <linux/export.h>

--- 19 unchanged lines hidden (view full) ---

28}
29
30static struct uts_namespace *create_uts_ns(void)
31{
32 struct uts_namespace *uts_ns;
33
34 uts_ns = kmem_cache_alloc(uts_ns_cache, GFP_KERNEL);
35 if (uts_ns)
36 kref_init(&uts_ns->kref);
36 refcount_set(&uts_ns->ns.count, 1);
37 return uts_ns;
38}
39
40/*
41 * Clone a new ns copying an original utsname, setting refcount to 1
42 * @old_ns: namespace to clone
43 * Return ERR_PTR(-ENOMEM) on error (failure to allocate), new ns otherwise
44 */

--- 53 unchanged lines hidden (view full) ---

98 return old_ns;
99
100 new_ns = clone_uts_ns(user_ns, old_ns);
101
102 put_uts_ns(old_ns);
103 return new_ns;
104}
105
37 return uts_ns;
38}
39
40/*
41 * Clone a new ns copying an original utsname, setting refcount to 1
42 * @old_ns: namespace to clone
43 * Return ERR_PTR(-ENOMEM) on error (failure to allocate), new ns otherwise
44 */

--- 53 unchanged lines hidden (view full) ---

98 return old_ns;
99
100 new_ns = clone_uts_ns(user_ns, old_ns);
101
102 put_uts_ns(old_ns);
103 return new_ns;
104}
105
106void free_uts_ns(struct kref *kref)
106void free_uts_ns(struct uts_namespace *ns)
107{
107{
108 struct uts_namespace *ns;
109
110 ns = container_of(kref, struct uts_namespace, kref);
111 dec_uts_namespaces(ns->ucounts);
112 put_user_ns(ns->user_ns);
113 ns_free_inum(&ns->ns);
114 kmem_cache_free(uts_ns_cache, ns);
115}
116
117static inline struct uts_namespace *to_uts_ns(struct ns_common *ns)
118{

--- 62 unchanged lines hidden ---
108 dec_uts_namespaces(ns->ucounts);
109 put_user_ns(ns->user_ns);
110 ns_free_inum(&ns->ns);
111 kmem_cache_free(uts_ns_cache, ns);
112}
113
114static inline struct uts_namespace *to_uts_ns(struct ns_common *ns)
115{

--- 62 unchanged lines hidden ---