Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

uts: use ns_common_init()

Don't cargo-cult the same thing over and over.

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>

+2 -14
+2 -14
kernel/utsname.c
··· 27 27 dec_ucount(ucounts, UCOUNT_UTS_NAMESPACES); 28 28 } 29 29 30 - static 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 - refcount_set(&uts_ns->ns.count, 1); 37 - return uts_ns; 38 - } 39 - 40 30 /* 41 31 * Clone a new ns copying an original utsname, setting refcount to 1 42 32 * @old_ns: namespace to clone ··· 45 55 goto fail; 46 56 47 57 err = -ENOMEM; 48 - ns = create_uts_ns(); 58 + ns = kmem_cache_zalloc(uts_ns_cache, GFP_KERNEL); 49 59 if (!ns) 50 60 goto fail_dec; 51 61 52 - err = ns_alloc_inum(&ns->ns); 62 + err = ns_common_init(&ns->ns, &utsns_operations, true); 53 63 if (err) 54 64 goto fail_free; 55 65 56 66 ns->ucounts = ucounts; 57 - ns->ns.ops = &utsns_operations; 58 - 59 67 down_read(&uts_sem); 60 68 memcpy(&ns->name, &old_ns->name, sizeof(ns->name)); 61 69 ns->user_ns = get_user_ns(user_ns);