[Top] [All Lists]

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

To: xfs-oss <xfs@xxxxxxxxxxx>
Subject: [PATCH] xfs: don't send null bp to xfs_trans_brelse()
From: Eric Sandeen <sandeen@xxxxxxxxxx>
Date: Tue, 10 Jun 2014 17:13:21 -0500
Delivered-to: xfs@xxxxxxxxxxx
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.5.0
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.

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

diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
index 6cc5f67..41f7a42 100644
--- a/fs/xfs/xfs_da_btree.c
+++ b/fs/xfs/xfs_da_btree.c
@@ -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;

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