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

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