diff mbox series

fs/jffs2: Fix potential NULL dereference in jffs2_add_frag_to_fragtree()

Message ID 1648797810-27042-1-git-send-email-baihaowen@meizu.com
State New
Delegated to: Richard Weinberger
Headers show
Series fs/jffs2: Fix potential NULL dereference in jffs2_add_frag_to_fragtree() | expand

Commit Message

Haowen Bai April 1, 2022, 7:23 a.m. UTC
this could be null, so we need to checking null before dereference

Signed-off-by: Haowen Bai <baihaowen@meizu.com>
---
 fs/jffs2/nodelist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/fs/jffs2/nodelist.c b/fs/jffs2/nodelist.c
index b86c78d178c6..ed3b3b25bfab 100644
--- a/fs/jffs2/nodelist.c
+++ b/fs/jffs2/nodelist.c
@@ -246,7 +246,7 @@  static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *r
 		return no_overlapping_node(c, root, newfrag, this, lastend);
 	}
 
-	if (this->node)
+	if (this && this->node)
 		dbg_fragtree2("dealing with frag %u-%u, phys %#08x(%d).\n",
 		this->ofs, this->ofs + this->size,
 		ref_offset(this->node->raw), ref_flags(this->node->raw));