xfs
[Top] [All Lists]

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

To: xfs-oss <xfs@xxxxxxxxxxx>
Subject: [PATCH 1/2] xfs: don't send null bp to xfs_trans_brelse()
From: Eric Sandeen <sandeen@xxxxxxxxxxx>
Date: Wed, 01 Oct 2014 10:22:19 -0500
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <542C1B36.5080804@xxxxxxxxxx>
References: <542C1B36.5080804@xxxxxxxxxx>
In this case, if bp is NULL, error is set, and we send a
NULL bp to xfs_trans_brelse, which will try to dereference it.

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

Coverity spotted this.

Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
---

diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index 2c42ae2..fd82753 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -2563,7 +2563,8 @@ xfs_da_get_buf(
                                    mapp, nmap, 0);
        error = bp ? bp->b_error : -EIO;
        if (error) {
-               xfs_trans_brelse(trans, bp);
+               if (bp)
+                       xfs_trans_brelse(trans, bp);
                goto out_free;
        }
 

<Prev in Thread] Current Thread [Next in Thread>