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

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