6f381c
From 7f5bfbd5485e1cb779d7568cabb5783651fd9da3 Mon Sep 17 00:00:00 2001
6f381c
From: Michael Olbrich <m.olbrich@pengutronix.de>
6f381c
Date: Fri, 6 Sep 2019 15:04:01 +0200
6f381c
Subject: [PATCH] pstore: fix use after free
6f381c
6f381c
The memory is still needed in the sd_journal_sendv() after the 'if' block.
6f381c
6f381c
(cherry picked from commit 1e19f5ac0d680a63eccae7ef1fc6ce225dca0bbf)
6f381c
6f381c
Related: #2158832
6f381c
---
6f381c
 src/pstore/pstore.c | 2 +-
6f381c
 1 file changed, 1 insertion(+), 1 deletion(-)
6f381c
6f381c
diff --git a/src/pstore/pstore.c b/src/pstore/pstore.c
6f381c
index eb251d61c8..cafb1804c6 100644
6f381c
--- a/src/pstore/pstore.c
6f381c
+++ b/src/pstore/pstore.c
6f381c
@@ -114,6 +114,7 @@ static int compare_pstore_entries(const void *_a, const void *_b) {
6f381c
 
6f381c
 static int move_file(PStoreEntry *pe, const char *subdir) {
6f381c
         _cleanup_free_ char *ifd_path = NULL, *ofd_path = NULL;
6f381c
+        _cleanup_free_ void *field = NULL;
6f381c
         const char *suffix, *message;
6f381c
         struct iovec iovec[2];
6f381c
         int n_iovec = 0, r;
6f381c
@@ -135,7 +136,6 @@ static int move_file(PStoreEntry *pe, const char *subdir) {
6f381c
         iovec[n_iovec++] = IOVEC_MAKE_STRING(message);
6f381c
 
6f381c
         if (pe->content_size > 0) {
6f381c
-                _cleanup_free_ void *field = NULL;
6f381c
                 size_t field_size;
6f381c
 
6f381c
                 field_size = strlen("FILE=") + pe->content_size;