From: Eric Sandeen Date: Mon, 14 Apr 2014 06:12:43 +0000 (+1000) Subject: xfs_logprint: fix leak in error path of xlog_print_record() X-Git-Tag: v3.2.0-rc1~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=04536baecea312c58305452c5cc600eca44fd847;p=thirdparty%2Fxfsprogs-dev.git 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 --- 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; + } } }