From: Julia Lawall <julia@diku.dk>
Date: Wed, 22 Jul 2009 20:49:01 +0000 (-0400)
Subject: Btrfs: adjust NULL test
X-Git-Tag: firefly_0821_release~13200^2~21
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=33c17ad5717c887568c1de61f15e5d58ed66d189;p=firefly-linux-kernel-4.4.55.git

Btrfs: adjust NULL test

Move the call to BUG_ON to before the dereference of the tested value.

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
---

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index a48c084f6d3a..3ea827ddf0fe 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2607,8 +2607,8 @@ noinline int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
 	if (root->ref_cows)
 		btrfs_drop_extent_cache(inode, new_size & (~mask), (u64)-1, 0);
 	path = btrfs_alloc_path();
-	path->reada = -1;
 	BUG_ON(!path);
+	path->reada = -1;
 
 	/* FIXME, add redo link to tree so we don't leak on crash */
 	key.objectid = inode->i_ino;