Blame SOURCES/0035-monitor-Avoid-segfault-when-calling-NULL-get_bad_blo.patch

b33395
From 9ae62977b51dab0f4bb46b1c8ea5ebd1705b2f4d Mon Sep 17 00:00:00 2001
b33395
From: Logan Gunthorpe <logang@deltatee.com>
b33395
Date: Wed, 22 Jun 2022 14:25:10 -0600
b33395
Subject: [PATCH 35/52] monitor: Avoid segfault when calling NULL
b33395
 get_bad_blocks
b33395
b33395
Not all struct superswitch implement a get_bad_blocks() function,
b33395
yet mdmon seems to call it without checking for NULL and thus
b33395
occasionally segfaults in the test 10ddf-geometry.
b33395
b33395
Fix this by checking for NULL before calling it.
b33395
b33395
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
b33395
Acked-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
b33395
Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
b33395
---
b33395
 monitor.c | 3 +++
b33395
 1 file changed, 3 insertions(+)
b33395
b33395
diff --git a/monitor.c b/monitor.c
b33395
index b877e595..820a93d0 100644
b33395
--- a/monitor.c
b33395
+++ b/monitor.c
b33395
@@ -311,6 +311,9 @@ static int check_for_cleared_bb(struct active_array *a, struct mdinfo *mdi)
b33395
 	struct md_bb *bb;
b33395
 	int i;
b33395
 
b33395
+	if (!ss->get_bad_blocks)
b33395
+		return -1;
b33395
+
b33395
 	/*
b33395
 	 * Get a list of bad blocks for an array, then read list of
b33395
 	 * acknowledged bad blocks from kernel and compare it against metadata
b33395
-- 
b33395
2.31.1
b33395