projects/linux·commit 83d5f018

xfs: cancel failed transaction in xfs_fs_commit_blocks()

83d5f018 · Eric Sandeen <[email protected]> · 2015-02-24 10:15:18 +11:00

If xfs_trans_reserve fails we don't cancel the transaction,
and we'll leak the allocated transaction pointer.

Spotted by Coverity.

Signed-off-by: Eric Sandeen <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Signed-off-by: Dave Chinner <[email protected]>
Commit
83d5f01858b56db69c8e4ca5389ef7c29bfdb5dd
Parents
fc921566

Changes

1 files changed · +3 −1

FileStatusAddDelContent
fs/xfs/xfs_pnfs.cmodified+3−1View file

fs/xfs/xfs_pnfs.c

View file
diff --git a/fs/xfs/xfs_pnfs.c b/fs/xfs/xfs_pnfs.c
index 4b33ef1..365dd57 100644
--- a/fs/xfs/xfs_pnfs.c
+++ b/fs/xfs/xfs_pnfs.c
@@ -300,8 +300,10 @@ xfs_fs_commit_blocks(
tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 0, 0);
- if (error)
+ if (error) {
+ xfs_trans_cancel(tp, 0);
goto out_drop_iolock;
+ }
xfs_ilock(ip, XFS_ILOCK_EXCL);
xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);