chiark / gitweb /
json: fix a mem leak
[elogind.git] / src / shared / machine-pool.c
index 3eafb9443a1cdec322122580aac6a076b4f2b134..9920d150abbada3774956311f8a3aa90b6098de2 100644 (file)
@@ -25,6 +25,8 @@
 #include <sys/mount.h>
 
 #include "util.h"
+#include "process-util.h"
+#include "lockfile-util.h"
 #include "mkdir.h"
 #include "btrfs-util.h"
 #include "path-util.h"
@@ -140,8 +142,9 @@ static int setup_machine_raw(uint64_t size, sd_bus_error *error) {
                 goto fail;
         }
 
-        if (renameat2(AT_FDCWD, tmp, AT_FDCWD, "/var/lib/machines.raw", RENAME_NOREPLACE) < 0) {
-                r = sd_bus_error_set_errnof(error, errno, "Failed to move /var/lib/machines.raw into place: %m");
+        r = rename_noreplace(AT_FDCWD, tmp, AT_FDCWD, "/var/lib/machines.raw");
+        if (r < 0) {
+                sd_bus_error_set_errnof(error, r, "Failed to move /var/lib/machines.raw into place: %m");
                 goto fail;
         }
 
@@ -151,8 +154,7 @@ static int setup_machine_raw(uint64_t size, sd_bus_error *error) {
         return r;
 
 fail:
-        if (tmp)
-                unlink_noerrno(tmp);
+        unlink_noerrno(tmp);
 
         if (pid > 1)
                 kill_and_sigcont(pid, SIGKILL);