Skip to contentSkip to conversation

xfs: don't send null bp to xfs_trans_brelse()

PATCH In review Eric Sandeen 2 participants 2 messages Jun 10, 2014 – Jun 12, 2014 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: don't send null bp to xfs_trans_brelse()

In this case, if bp is null, error is set, and we send bp to xfs_trans_brelse, which will try to dereference it.

Test whether we actualy have a buffer before we try to free it.

Coverity spotted this.

---

fs/xfs/xfs_da_btree.c +2 -1
index 6cc5f67..41f7a42 100644
@@ -2571,7 +2571,8 @@ xfs_da_get_buf(
 				    mapp, nmap, 0);
 	error = bp ? bp->b_error : XFS_ERROR(EIO);
 	if (error) {
-		xfs_trans_brelse(trans, bp);
+		if (bp)
+			xfs_trans_brelse(trans, bp);
 		goto out_free;
 	}
 

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

Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Eric Sandeen

In this case, if bp is null, error is set, and we send bp to xfs_trans_brelse, which will try to dereference it.

Test whether we actualy have a buffer before we try to free it.

Coverity spotted this.

---

Quoted 16 lines
fs/xfs/xfs_da_btree.c +2 -1
index 6cc5f67..41f7a42 100644
@@ -2571,7 +2571,8 @@ xfs_da_get_buf(
 				    mapp, nmap, 0);
 	error = bp ? bp->b_error : XFS_ERROR(EIO);
 	if (error) {
-		xfs_trans_brelse(trans, bp);
+		if (bp)
+			xfs_trans_brelse(trans, bp);
 		goto out_free;
 	}
 
Quoted 4 lines

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

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