xfs
[Top] [All Lists]

[PATCH 07/14] xfs_logprint: fix leak in error path of xlog_print_record(

To: xfs@xxxxxxxxxxx
Subject: [PATCH 07/14] xfs_logprint: fix leak in error path of xlog_print_record()
From: Eric Sandeen <sandeen@xxxxxxxxxx>
Date: Tue, 8 Apr 2014 18:24:57 -0500
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1396999504-13769-1-git-send-email-sandeen@xxxxxxxxxx>
References: <1396999504-13769-1-git-send-email-sandeen@xxxxxxxxxx>
In 2 error paths we returned without freeing the allocated buf.
Collapse them into a compound test & free buf on the way out.

Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
---
 logprint/log_misc.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/logprint/log_misc.c b/logprint/log_misc.c
index 52f1e85..a022df4 100644
--- a/logprint/log_misc.c
+++ b/logprint/log_misc.c
@@ -942,11 +942,12 @@ xlog_print_record(
             */
            if (be32_to_cpu(rhead->h_cycle) !=
                        be32_to_cpu(*(__be32 *)ptr)) {
-               if (*read_type == FULL_READ)
-                   return -1;
-               else if (be32_to_cpu(rhead->h_cycle) + 1 !=
-                       be32_to_cpu(*(__be32 *)ptr))
-                   return -1;
+               if ((*read_type == FULL_READ) ||
+                   (be32_to_cpu(rhead->h_cycle) + 1 !=
+                               be32_to_cpu(*(__be32 *)ptr))) {
+                       free(buf);
+                       return -1;
+               }
            }
        }
 
-- 
1.7.1

<Prev in Thread] Current Thread [Next in Thread>