xfs
[Top] [All Lists]

[PATCH 02/14] xfs: add missing bmap cancel calls in error paths

To: xfs@xxxxxxxxxxx
Subject: [PATCH 02/14] xfs: add missing bmap cancel calls in error paths
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Mon, 15 Feb 2016 17:18:13 +1100
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1455517105-20033-1-git-send-email-david@xxxxxxxxxxxxx>
References: <1455517105-20033-1-git-send-email-david@xxxxxxxxxxxxx>
From: Brian Foster <bfoster@xxxxxxxxxx>

Source kernel commit d4a97a04227d5ba91b91888a016e2300861cfbc7

If a failure occurs after the bmap free list is populated and before
xfs_bmap_finish() completes successfully (which returns a partial
list on failure), the bmap free list must be cancelled. Otherwise,
the extent items on the list are never freed and a memory leak
occurs.

Several random error paths throughout the code suffer this problem.
Fix these up such that xfs_bmap_cancel() is always called on error.

Signed-off-by: Brian Foster <bfoster@xxxxxxxxxx>
Reviewed-by: Dave Chinner <dchinner@xxxxxxxxxx>
Signed-off-by: Dave Chinner <david@xxxxxxxxxxxxx>
---
 libxfs/xfs_bmap.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c
index aef7cf3..b9e58e2 100644
--- a/libxfs/xfs_bmap.c
+++ b/libxfs/xfs_bmap.c
@@ -5938,6 +5938,7 @@ xfs_bmap_split_extent(
        return xfs_trans_commit(tp);
 
 out:
+       xfs_bmap_cancel(&free_list);
        xfs_trans_cancel(tp);
        return error;
 }
-- 
2.5.0

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