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

Joseph Qi joseph.qi at huawei.com
Thu Mar 3 02:58:46 PST 2016


From: Norton.Zhu <norton.zhu at huawei.com>

This happens while finishing ocfs2_bitmap_merge_region with root node
colored RED (only one node in the tree).
After another node adds in and do rb_insert_color, segfault occurs
because of NULL pointer.

Signed-off-by: Norton.Zhu <norton.zhu at huawei.com>
Reviewed-by: Jun Piao <piaojun at huawei.com>
Signed-off-by: Joseph Qi <joseph.qi 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