Skip to content

Commit

Permalink
xfs: ensure committed is initialized in xfs_trans_roll
Browse files Browse the repository at this point in the history
__xfs_trans_roll() can return without setting the
*committed argument; this was a problem for xfs_bmap_finish():

        int       committed;/* xact committed or not */
...
        error = __xfs_trans_roll(tp, ip, &committed);
        if (error) {
...
                if (committed) {

and we tested an uninitialized "committed" variable on the
error path.  No caller is preserving "committed" state across
calls to __xfs_trans_roll(), so just initialize committed inside
the function to avoid future errors like this.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
  • Loading branch information
Eric Sandeen authored and Dave Chinner committed Mar 15, 2016
1 parent d34999c commit cc07eed
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fs/xfs/xfs_trans.c
Original file line number Diff line number Diff line change
@@ -1028,6 +1028,8 @@ __xfs_trans_roll(
struct xfs_trans_res tres;
int error;

*committed = 0;

/*
* Ensure that the inode is always logged.
*/
@@ -1082,6 +1084,6 @@ xfs_trans_roll(
struct xfs_trans **tpp,
struct xfs_inode *dp)
{
int committed = 0;
int committed;
return __xfs_trans_roll(tpp, dp, &committed);
}

0 comments on commit cc07eed

Please sign in to comment.