diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c
index 82743480eec..527043a2b39 100644
--- a/src/basic/cgroup-util.c
+++ b/src/basic/cgroup-util.c
@@ -533,14 +533,12 @@ static int controller_is_v1_accessible(const char *root, const char *controller)
         assert(controller);
 
         dn = controller_to_dirname(controller);
-        cpath = strjoina("/sys/fs/cgroup/", dn);
-        if (root)
-                /* Also check that:
-                 * - possible subcgroup is created at root,
-                 * - we can modify the hierarchy.
-                 * "Leak" cpath on stack */
-                cpath = strjoina(cpath, root, "/cgroup.procs");
 
+        /* If root if specified, we check that:
+         * - possible subcgroup is created at root,
+         * - we can modify the hierarchy. */
+
+        cpath = strjoina("/sys/fs/cgroup/", dn, root, root ? "/cgroup.procs" : NULL);
         if (laccess(cpath, root ? W_OK : F_OK) < 0)
                 return -errno;
 
diff --git a/src/test/test-string-util.c b/src/test/test-string-util.c
index fec9577d1f1..15ea24ae4be 100644
--- a/src/test/test-string-util.c
+++ b/src/test/test-string-util.c
@@ -345,6 +345,12 @@ static void test_strjoina(void) {
 
         actual = strjoina("foo", NULL, "bar");
         assert_se(streq(actual, "foo"));
+
+        actual = strjoina("/sys/fs/cgroup/", "dn", "/a/b/c", "/cgroup.procs");
+        assert_se(streq(actual, "/sys/fs/cgroup/dn/a/b/c/cgroup.procs"));
+
+        actual = strjoina("/sys/fs/cgroup/", "dn", NULL, NULL);
+        assert_se(streq(actual, "/sys/fs/cgroup/dn"));
 }
 
 static void test_strjoin(void) {