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

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