[Ocfs2-tools-devel] [PATCH] libocfs2: Fix segfalut BUG while doing fsck

Norton.Zhu norton.zhu at huawei.com
Thu Aug 6 23:00:23 PDT 2015


Fix rb_insert_color segfault BUG
This happens while finishing ocfs2_bitmap_merge_region
with root node colored RED(only one node in the tree)
After another node add in and do rb_insert_color,
segfault occurred(NULL pointer).

Signed-off-by: Norton.Zhu <norton.zhu at huawei.com>
Reviewed-by: Jun Piao <piaojun at huawei.com>

---
 libocfs2/kernel-rbtree.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libocfs2/kernel-rbtree.c b/libocfs2/kernel-rbtree.c
index 1c8f911..629d472 100644
--- a/libocfs2/kernel-rbtree.c
+++ b/libocfs2/kernel-rbtree.c
@@ -77,6 +77,8 @@ void rb_insert_color(struct rb_node *node, struct rb_root *root)
 	while ((parent = node->rb_parent) && parent->rb_color == RB_RED)
 	{
 		gparent = parent->rb_parent;
+		if (!gparent)
+			break;

 		if (parent == gparent->rb_left)
 		{
-- 
1.8.4.3




More information about the Ocfs2-tools-devel mailing list