[XFS] Fix double free of log tickets
authorDave Chinner <david@fromorbit.com>
Mon, 17 Nov 2008 06:37:10 +0000 (17:37 +1100)
committerLachlan McIlroy <lachlan@redback.melbourne.sgi.com>
Mon, 17 Nov 2008 06:37:10 +0000 (17:37 +1100)
commitcc09c0dc57de7f7d2ed89d480b5653e5f6a32f2c
tree3c6145ccb00f603c47e020cfa45f159ab76cf9bf
parent6307091fe69ae74747298bdcaf43119ad67bda3a
[XFS] Fix double free of log tickets

When an I/O error occurs during an intermediate commit on a rolling
transaction, xfs_trans_commit() will free the transaction structure
and the related ticket. However, the duplicate transaction that
gets used as the transaction continues still contains a pointer
to the ticket. Hence when the duplicate transaction is cancelled
and freed, we free the ticket a second time.

Add reference counting to the ticket so that we hold an extra
reference to the ticket over the transaction commit. We drop the
extra reference once we have checked that the transaction commit
did not return an error, thus avoiding a double free on commit
error.

Credit to Nick Piggin for tripping over the problem.

SGI-PV: 989741

Signed-off-by: Dave Chinner <david@fromorbit.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
fs/xfs/xfs_bmap.c
fs/xfs/xfs_inode.c
fs/xfs/xfs_log.c
fs/xfs/xfs_log.h
fs/xfs/xfs_log_priv.h
fs/xfs/xfs_trans.c
fs/xfs/xfs_utils.c
fs/xfs/xfs_vnodeops.c