All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: Eric Sandeen <sandeen@redhat.com>
Cc: xfs-oss <xfs@oss.sgi.com>
Subject: Re: [PATCH] xfs: fix error gotos in xfs_setattr_nonsize
Date: Mon, 31 Aug 2015 14:19:36 -0400	[thread overview]
Message-ID: <20150831181935.GC16371@bfoster.bfoster> (raw)
In-Reply-To: <55DF80BA.9020101@redhat.com>

On Thu, Aug 27, 2015 at 04:27:22PM -0500, Eric Sandeen wrote:
> 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: Eric Sandeen <sandeen@redhat.com>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

> 
> Full disclosure: build tested only, as these are error paths
> which we don't easily fail...
> 
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index 766b23f..8294132 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -609,7 +609,7 @@ xfs_setattr_nonsize(
>  	tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
>  	error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 0, 0);
>  	if (error)
> -		goto out_dqrele;
> +		goto out_trans_cancel;
>  
>  	xfs_ilock(ip, XFS_ILOCK_EXCL);
>  
> @@ -640,7 +640,7 @@ xfs_setattr_nonsize(
>  						NULL, capable(CAP_FOWNER) ?
>  						XFS_QMOPT_FORCE_RES : 0);
>  			if (error)	/* out of quota */
> -				goto out_trans_cancel;
> +				goto out_unlock;
>  		}
>  	}
>  
> @@ -729,10 +729,10 @@ xfs_setattr_nonsize(
>  
>  	return 0;
>  
> +out_unlock:
> +	xfs_iunlock(ip, XFS_ILOCK_EXCL);
>  out_trans_cancel:
>  	xfs_trans_cancel(tp);
> -	xfs_iunlock(ip, XFS_ILOCK_EXCL);
> -out_dqrele:
>  	xfs_qm_dqrele(udqp);
>  	xfs_qm_dqrele(gdqp);
>  	return error;
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

      reply	other threads:[~2015-08-31 18:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-27 21:27 [PATCH] xfs: fix error gotos in xfs_setattr_nonsize Eric Sandeen
2015-08-31 18:19 ` Brian Foster [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150831181935.GC16371@bfoster.bfoster \
    --to=bfoster@redhat.com \
    --cc=sandeen@redhat.com \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.