From 04536baecea312c58305452c5cc600eca44fd847 Mon Sep 17 00:00:00 2001 From: Eric Sandeen Date: Mon, 14 Apr 2014 16:12:43 +1000 Subject: [PATCH] xfs_logprint: fix leak in error path of xlog_print_record() 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 Reviewed-by: Brian Foster Signed-off-by: Dave Chinner --- logprint/log_misc.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/logprint/log_misc.c b/logprint/log_misc.c index 52f1e85c3..a022df42f 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; + } } } -- 2.47.2