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

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