]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cgroup-setup: use path_join() to get path to cgroup attribute 37026/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 14 Apr 2025 21:12:05 +0000 (06:12 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 15 Apr 2025 18:56:04 +0000 (03:56 +0900)
We already have the path to the cgroup. Hence, it is not necessary to
call cg_get_path() again.

src/shared/cgroup-setup.c

index f4d93c2cb0764e51781d0e196b41657a3842635c..51f04e8c6b55d7eb7026d2e5788832915e021ecc 100644 (file)
@@ -222,18 +222,16 @@ int cg_set_access(
 
         /* Configure access to the cgroup's attributes */
         FOREACH_ELEMENT(i, attributes) {
-                fs = mfree(fs);
+                _cleanup_free_ char *a = path_join(fs, i->name);
+                if (!a)
+                        return -ENOMEM;
 
-                r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, path, i->name, &fs);
-                if (r < 0)
-                        return r;
-
-                r = chmod_and_chown(fs, 0644, uid, gid);
+                r = chmod_and_chown(a, 0644, uid, gid);
                 if (r < 0) {
                         if (i->fatal)
                                 return r;
 
-                        log_debug_errno(r, "Failed to set access on cgroup %s, ignoring: %m", fs);
+                        log_debug_errno(r, "Failed to set access on cgroup %s, ignoring: %m", a);
                 }
         }