From b2b270e1d1b4ddb761dd05f20a1d3853d9067b39 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 15 Apr 2025 06:12:05 +0900 Subject: [PATCH] cgroup-setup: use path_join() to get path to cgroup attribute We already have the path to the cgroup. Hence, it is not necessary to call cg_get_path() again. --- src/shared/cgroup-setup.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/shared/cgroup-setup.c b/src/shared/cgroup-setup.c index f4d93c2cb07..51f04e8c6b5 100644 --- a/src/shared/cgroup-setup.c +++ b/src/shared/cgroup-setup.c @@ -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); } } -- 2.47.3