[06/10] btrfs-progs: vailidate pointer before dereferencing it in btrfs_cow_block()
diff mbox

Message ID 1445254680-11102-7-git-send-email-guaneryu@gmail.com
State New
Headers show

Commit Message

Eryu Guan Oct. 19, 2015, 11:37 a.m. UTC
Check trans before dereferencing it.

Signed-off-by: Eryu Guan <guaneryu@gmail.com>
---
 ctree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Sterba Oct. 19, 2015, 1:47 p.m. UTC | #1
On Mon, Oct 19, 2015 at 07:37:56PM +0800, Eryu Guan wrote:
> Check trans before dereferencing it.

Have you found a code path where 'trans' can be NULL? A quick search did
not reveal anything.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/ctree.c b/ctree.c
index 1434007..f9d972a 100644
--- a/ctree.c
+++ b/ctree.c
@@ -356,7 +356,7 @@  int btrfs_cow_block(struct btrfs_trans_handle *trans,
 		WARN_ON(1);
 	}
 	*/
-	if (trans->transid != root->fs_info->generation) {
+	if (trans && trans->transid != root->fs_info->generation) {
 		printk(KERN_CRIT "trans %llu running %llu\n",
 			(unsigned long long)trans->transid,
 			(unsigned long long)root->fs_info->generation);