Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1a7ccad8 authored by Eric Sandeen's avatar Eric Sandeen Committed by Dave Chinner
Browse files

xfs: fix error gotos in xfs_setattr_nonsize



As the code stands today, if xfs_trans_reserve() fails, we
goto out_dqrele, which does not free the allocated transaction.

Fix up the goto targets to undo everything properly.

Addresses-Coverity-Id: 145571
Signed-off-by: default avatarEric Sandeen <sandeen@redhat.com>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent 8774cf8b
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -609,7 +609,7 @@ xfs_setattr_nonsize(
	tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
	tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
	error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 0, 0);
	error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 0, 0);
	if (error)
	if (error)
		goto out_dqrele;
		goto out_trans_cancel;


	xfs_ilock(ip, XFS_ILOCK_EXCL);
	xfs_ilock(ip, XFS_ILOCK_EXCL);


@@ -640,7 +640,7 @@ xfs_setattr_nonsize(
						NULL, capable(CAP_FOWNER) ?
						NULL, capable(CAP_FOWNER) ?
						XFS_QMOPT_FORCE_RES : 0);
						XFS_QMOPT_FORCE_RES : 0);
			if (error)	/* out of quota */
			if (error)	/* out of quota */
				goto out_trans_cancel;
				goto out_unlock;
		}
		}
	}
	}


@@ -729,10 +729,10 @@ xfs_setattr_nonsize(


	return 0;
	return 0;


out_unlock:
	xfs_iunlock(ip, XFS_ILOCK_EXCL);
out_trans_cancel:
out_trans_cancel:
	xfs_trans_cancel(tp);
	xfs_trans_cancel(tp);
	xfs_iunlock(ip, XFS_ILOCK_EXCL);
out_dqrele:
	xfs_qm_dqrele(udqp);
	xfs_qm_dqrele(udqp);
	xfs_qm_dqrele(gdqp);
	xfs_qm_dqrele(gdqp);
	return error;
	return error;