public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix a couple coverity-spotted issues
@ 2015-02-23 18:57 Eric Sandeen
  2015-02-23 18:59 ` [PATCH 1/2] xfs: Ensure we have target_ip for RENAME_EXCHANGE Eric Sandeen
  2015-02-23 19:00 ` [PATCH 2/2] xfs: cancel failed transaction in xfs_fs_commit_blocks() Eric Sandeen
  0 siblings, 2 replies; 5+ messages in thread
From: Eric Sandeen @ 2015-02-23 18:57 UTC (permalink / raw)
  To: xfs-oss

<EOM>

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] xfs: Ensure we have target_ip for RENAME_EXCHANGE
  2015-02-23 18:57 [PATCH 0/2] Fix a couple coverity-spotted issues Eric Sandeen
@ 2015-02-23 18:59 ` Eric Sandeen
  2015-02-23 20:48   ` Christoph Hellwig
  2015-02-23 19:00 ` [PATCH 2/2] xfs: cancel failed transaction in xfs_fs_commit_blocks() Eric Sandeen
  1 sibling, 1 reply; 5+ messages in thread
From: Eric Sandeen @ 2015-02-23 18:59 UTC (permalink / raw)
  To: xfs-oss; +Cc: Carlos Maiolino

We shouldn't get here with RENAME_EXCHANGE set and no
target_ip, but let's be defensive, because xfs_cross_rename()
will dereference it.

Spotted by Coverity.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index daafa1f..6163767 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -2867,6 +2867,10 @@ xfs_rename(
 	 * Handle RENAME_EXCHANGE flags
 	 */
 	if (flags & RENAME_EXCHANGE) {
+		if (target_ip == NULL) {
+			error = -EINVAL;
+			goto error_return;
+		}
 		error = xfs_cross_rename(tp, src_dp, src_name, src_ip,
 					 target_dp, target_name, target_ip,
 					 &free_list, &first_block, spaceres);

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] xfs: cancel failed transaction in xfs_fs_commit_blocks()
  2015-02-23 18:57 [PATCH 0/2] Fix a couple coverity-spotted issues Eric Sandeen
  2015-02-23 18:59 ` [PATCH 1/2] xfs: Ensure we have target_ip for RENAME_EXCHANGE Eric Sandeen
@ 2015-02-23 19:00 ` Eric Sandeen
  2015-02-23 20:48   ` Christoph Hellwig
  1 sibling, 1 reply; 5+ messages in thread
From: Eric Sandeen @ 2015-02-23 19:00 UTC (permalink / raw)
  To: xfs-oss; +Cc: Christoph Hellwig

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>
---

diff --git a/fs/xfs/xfs_pnfs.c b/fs/xfs/xfs_pnfs.c
index 4b33ef1..365dd57 100644
--- a/fs/xfs/xfs_pnfs.c
+++ b/fs/xfs/xfs_pnfs.c
@@ -300,8 +300,10 @@ xfs_fs_commit_blocks(
 
 	tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
 	error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 0, 0);
-	if (error)
+	if (error) {
+		xfs_trans_cancel(tp, 0);
 		goto out_drop_iolock;
+	}
 
 	xfs_ilock(ip, XFS_ILOCK_EXCL);
 	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] xfs: Ensure we have target_ip for RENAME_EXCHANGE
  2015-02-23 18:59 ` [PATCH 1/2] xfs: Ensure we have target_ip for RENAME_EXCHANGE Eric Sandeen
@ 2015-02-23 20:48   ` Christoph Hellwig
  0 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2015-02-23 20:48 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: Carlos Maiolino, xfs-oss

Seems a little pointless, but given that we overload these
different operations over ->rename making Coverity happy might
not be the worst idea.  Maybe we should just add a different
->rename_exchange methods given that there's not much shared
code anywhere.

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] xfs: cancel failed transaction in xfs_fs_commit_blocks()
  2015-02-23 19:00 ` [PATCH 2/2] xfs: cancel failed transaction in xfs_fs_commit_blocks() Eric Sandeen
@ 2015-02-23 20:48   ` Christoph Hellwig
  0 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2015-02-23 20:48 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: Christoph Hellwig, xfs-oss

On Mon, Feb 23, 2015 at 01:00:27PM -0600, Eric Sandeen wrote:
> If xfs_trans_reserve fails we don't cancel the transaction,
> and we'll leak the allocated transaction pointer.
> 
> Spotted by Coverity.

Thanks, looks good.

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-02-23 20:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-23 18:57 [PATCH 0/2] Fix a couple coverity-spotted issues Eric Sandeen
2015-02-23 18:59 ` [PATCH 1/2] xfs: Ensure we have target_ip for RENAME_EXCHANGE Eric Sandeen
2015-02-23 20:48   ` Christoph Hellwig
2015-02-23 19:00 ` [PATCH 2/2] xfs: cancel failed transaction in xfs_fs_commit_blocks() Eric Sandeen
2015-02-23 20:48   ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox