]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
cgroup: use ns_common_init()
authorChristian Brauner <brauner@kernel.org>
Fri, 12 Sep 2025 11:52:31 +0000 (13:52 +0200)
committerChristian Brauner <brauner@kernel.org>
Fri, 19 Sep 2025 12:26:13 +0000 (14:26 +0200)
Don't cargo-cult the same thing over and over.

Acked-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>
kernel/cgroup/namespace.c

index 144a464e45c66447235b3b265efcd1092f32c2a2..0391b6ab0bf1bef0a65af6d10c1c84323b0178bb 100644 (file)
@@ -21,20 +21,16 @@ static void dec_cgroup_namespaces(struct ucounts *ucounts)
 
 static struct cgroup_namespace *alloc_cgroup_ns(void)
 {
-       struct cgroup_namespace *new_ns;
+       struct cgroup_namespace *new_ns __free(kfree) = NULL;
        int ret;
 
        new_ns = kzalloc(sizeof(struct cgroup_namespace), GFP_KERNEL_ACCOUNT);
        if (!new_ns)
                return ERR_PTR(-ENOMEM);
-       ret = ns_alloc_inum(&new_ns->ns);
-       if (ret) {
-               kfree(new_ns);
+       ret = ns_common_init(&new_ns->ns, &cgroupns_operations, true);
+       if (ret)
                return ERR_PTR(ret);
-       }
-       refcount_set(&new_ns->ns.count, 1);
-       new_ns->ns.ops = &cgroupns_operations;
-       return new_ns;
+       return no_free_ptr(new_ns);
 }
 
 void free_cgroup_ns(struct cgroup_namespace *ns)