Skip to contentSkip to conversation

Fix a couple coverity-spotted issues

PATCH New Eric Sandeen 3 participants 5 messages Feb 23, 2015 XFS filesystem

lore
Share & tools
lore
#1 lore raw

PATCH 1/2 xfs: Ensure we have target_ip for RENAME_EXCHANGE

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.

---

fs/xfs/xfs_inode.c +4 -0
index daafa1f..6163767 100644
@@ -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
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] xfs: Ensure we have target_ip for RENAME_EXCHANGE

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.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#3 lore raw

PATCH 2/2 xfs: cancel failed transaction in xfs_fs_commit_blocks()

In reply to Eric Sandeen

If xfs_trans_reserve fails we don't cancel the transaction, and we'll leak the allocated transaction pointer.

Spotted by Coverity.

---

fs/xfs/xfs_pnfs.c +3 -1
index 4b33ef1..365dd57 100644
@@ -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
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs