dryang / rpms / systemd

Forked from rpms/systemd a year ago
Clone
6f381c
From 58000dc7dd93ff6e8357de64154b0849d3c17c5d Mon Sep 17 00:00:00 2001
6f381c
From: Yu Watanabe <watanabe.yu+github@gmail.com>
6f381c
Date: Mon, 22 Jul 2019 11:01:43 +0900
6f381c
Subject: [PATCH] pstore: remove temporary file on failure
6f381c
6f381c
(cherry picked from commit 03c5f6cc02648eeff3179b2b762d46b9e1889bb1)
6f381c
6f381c
Related: #2158832
6f381c
---
6f381c
 src/pstore/pstore.c | 6 +++---
6f381c
 1 file changed, 3 insertions(+), 3 deletions(-)
6f381c
6f381c
diff --git a/src/pstore/pstore.c b/src/pstore/pstore.c
6f381c
index 2fbef48543..ce8080ceed 100644
6f381c
--- a/src/pstore/pstore.c
6f381c
+++ b/src/pstore/pstore.c
6f381c
@@ -167,8 +167,8 @@ static int move_file(PStoreEntry *pe, const char *subdir) {
6f381c
 }
6f381c
 
6f381c
 static int write_dmesg(const char *dmesg, size_t size, const char *id) {
6f381c
-        _cleanup_(unlink_and_freep) char *ofd_path = NULL;
6f381c
-        _cleanup_free_ char *tmp_path = NULL;
6f381c
+        _cleanup_(unlink_and_freep) char *tmp_path = NULL;
6f381c
+        _cleanup_free_ char *ofd_path = NULL;
6f381c
         _cleanup_close_ int ofd = -1;
6f381c
         ssize_t wr;
6f381c
         int r;
6f381c
@@ -193,7 +193,7 @@ static int write_dmesg(const char *dmesg, size_t size, const char *id) {
6f381c
         r = link_tmpfile(ofd, tmp_path, ofd_path);
6f381c
         if (r < 0)
6f381c
                 return log_error_errno(r, "Failed to write temporary file %s: %m", ofd_path);
6f381c
-        ofd_path = mfree(ofd_path);
6f381c
+        tmp_path = mfree(tmp_path);
6f381c
 
6f381c
         return 0;
6f381c
 }