]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfsprogs: fix buffer leak in xlog_print_find_oldest
authorEric Sandeen <sandeen@redhat.com>
Thu, 1 Aug 2013 01:42:58 +0000 (01:42 +0000)
committerMark Tinguely <tinguely@eagdhcp-232-140.americas.sgi.com>
Fri, 9 Aug 2013 13:23:47 +0000 (08:23 -0500)
The error path in this function did not free the buffer
before returning.

Coverity found this one.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
logprint/log_print_all.c

index 462618623ba5c8de2b138c419b87e643970e017d..11944695bc92856aecc51a3b94d0ad8255844ea1 100644 (file)
@@ -29,7 +29,7 @@ xlog_print_find_oldest(
        xfs_buf_t       *bp;
        xfs_daddr_t     first_blk;
        uint            first_half_cycle, last_half_cycle;
-       int             error;
+       int             error = 0;
 
        if (xlog_find_zeroed(log, &first_blk))
                return 0;
@@ -43,17 +43,14 @@ xlog_print_find_oldest(
        last_half_cycle = xlog_get_cycle(XFS_BUF_PTR(bp));
        ASSERT(last_half_cycle != 0);
 
-       if (first_half_cycle == last_half_cycle) /* all cycle nos are same */
+       if (first_half_cycle == last_half_cycle) /* all cycle nos are same */
                *last_blk = 0;
-       } else {                /* have 1st and last; look for middle cycle */
+       else            /* have 1st and last; look for middle cycle */
                error = xlog_find_cycle_start(log, bp, first_blk,
                                              last_blk, last_half_cycle);
-               if (error)
-                       return error;
-       }
 
        xlog_put_bp(bp);
-       return 0;
+       return error;
 }
 
 void