]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/exec-credential: use rmdir_and_freep at one more place
authorMike Yuan <me@yhndnzj.com>
Wed, 11 Oct 2023 15:16:19 +0000 (23:16 +0800)
committerMike Yuan <me@yhndnzj.com>
Wed, 11 Oct 2023 18:36:15 +0000 (02:36 +0800)
src/core/exec-credential.c

index 4d4dadca90de1c5e4bd6cc1bc172fac8993d0359..ff2d795c7d90f3b6527a257fa311ea0ee57d5429 100644 (file)
@@ -932,7 +932,8 @@ int exec_setup_credentials(
 
         r = safe_fork("(sd-mkdcreds)", FORK_DEATHSIG|FORK_WAIT|FORK_NEW_MOUNTNS, NULL);
         if (r < 0) {
-                _cleanup_free_ char *t = NULL, *u = NULL;
+                _cleanup_(rmdir_and_freep) char *u = NULL; /* remove the temporary workspace if we can */
+                _cleanup_free_ char *t = NULL;
 
                 /* If this is not a privilege or support issue then propagate the error */
                 if (!ERRNO_IS_NOT_SUPPORTED(r) && !ERRNO_IS_PRIVILEGE(r))
@@ -967,9 +968,6 @@ int exec_setup_credentials(
                                 false,   /* it's OK to fall back to a plain directory if we can't mount anything */
                                 uid,
                                 gid);
-
-                (void) rmdir(u); /* remove the workspace again if we can. */
-
                 if (r < 0)
                         return r;