File 0086-super1-only-set-clustered-flag-when-bitmap-is-presen.patch of Package mdadm.7129

From 6438c249c4fed92cf6e5fb492d19f4c4f516ff6f Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.com>
Date: Fri, 4 Aug 2017 15:30:02 +1000
Subject: [PATCH] super1: only set clustered flag when bitmap is present
Git-commit: 6438c249c4fed92cf6e5fb492d19f4c4f516ff6f
Patch-mainline: mdadm-4.0
References: bsc#1047314

If no bitmap is present, then the test

	if (__le32_to_cpu(bsb->nodes) > 1)

accesses uninitialised memory.  So move that test inside
a test for a bitmap being present.

Note by Coly Li: This is a modified version for SLE12-SP2.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
 super1.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: mdadm-3.4/super1.c
===================================================================
--- mdadm-3.4.orig/super1.c
+++ mdadm-3.4/super1.c
@@ -927,14 +927,14 @@ static void getinfo_super1(struct supert
 	info->array.state =
 		(__le64_to_cpu(sb->resync_offset) == MaxSector)
 		? 1 : 0;
-	if (__le32_to_cpu(bsb->nodes) > 1)
-		info->array.state |= (1 << MD_SB_CLUSTERED);
 
 	info->data_offset = __le64_to_cpu(sb->data_offset);
 	info->component_size = __le64_to_cpu(sb->size);
-	if (sb->feature_map & __le32_to_cpu(MD_FEATURE_BITMAP_OFFSET))
+	if (sb->feature_map & __le32_to_cpu(MD_FEATURE_BITMAP_OFFSET)) {
 		info->bitmap_offset = (int32_t)__le32_to_cpu(sb->bitmap_offset);
-
+		if (__le32_to_cpu(bsb->nodes) > 1)
+			info->array.state |= (1 << MD_SB_CLUSTERED);
+	}
 	info->disk.major = 0;
 	info->disk.minor = 0;
 	info->disk.number = __le32_to_cpu(sb->dev_number);
openSUSE Build Service is sponsored by