Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xfs: cancel failed transaction in xfs_fs_commit_blocks()

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 <ssandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>

authored by

Eric Sandeen and committed by
Dave Chinner
83d5f018 fc921566

+3 -1
+3 -1
fs/xfs/xfs_pnfs.c
··· 300 300 301 301 tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE); 302 302 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 0, 0); 303 - if (error) 303 + if (error) { 304 + xfs_trans_cancel(tp, 0); 304 305 goto out_drop_iolock; 306 + } 305 307 306 308 xfs_ilock(ip, XFS_ILOCK_EXCL); 307 309 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);