diff mbox

[5/5] xfs: fix btree scrub deref check

Message ID 151001663224.26786.16638321559848220870.stgit@magnolia (mailing list archive)
State Accepted
Headers show

Commit Message

Darrick J. Wong Nov. 7, 2017, 1:03 a.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

The btree scrubber has some custom code to retrieve and check a btree
block via xfs_btree_lookup_get_block.  This function will either return
an error code (verifiers failed) or a *pblock will be untouched (bad
pointer).  Since we previously set *pblock to NULL, we need to check
*pblock, not pblock, to trigger the early bailout.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/scrub/btree.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)



--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Dave Chinner Nov. 9, 2017, 2:16 a.m. UTC | #1
On Mon, Nov 06, 2017 at 05:03:52PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> The btree scrubber has some custom code to retrieve and check a btree
> block via xfs_btree_lookup_get_block.  This function will either return
> an error code (verifiers failed) or a *pblock will be untouched (bad
> pointer).  Since we previously set *pblock to NULL, we need to check
> *pblock, not pblock, to trigger the early bailout.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Ah, the dangers of double pointers. Looks good.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
diff mbox

Patch

diff --git a/fs/xfs/scrub/btree.c b/fs/xfs/scrub/btree.c
index a814404..df07661 100644
--- a/fs/xfs/scrub/btree.c
+++ b/fs/xfs/scrub/btree.c
@@ -335,7 +335,7 @@  xfs_scrub_btree_get_block(
 
 	error = xfs_btree_lookup_get_block(bs->cur, level, pp, pblock);
 	if (!xfs_scrub_btree_process_error(bs->sc, bs->cur, level, &error) ||
-	    !pblock)
+	    !*pblock)
 		return error;
 
 	xfs_btree_get_block(bs->cur, level, pbp);