diff mbox series

[05/23] monitor: Avoid segfault when calling NULL get_bad_blocks

Message ID 20220728122101.28744-6-colyli@suse.de (mailing list archive)
State Not Applicable, archived
Delegated to: Jes Sorensen
Headers show
Series mdadm-CI for-jes/20220728: patches for merge | expand

Commit Message

Coly Li July 28, 2022, 12:20 p.m. UTC
From: Logan Gunthorpe <logang@deltatee.com>

Not all struct superswitch implement a get_bad_blocks() function,
yet mdmon seems to call it without checking for NULL and thus
occasionally segfaults in the test 10ddf-geometry.

Fix this by checking for NULL before calling it.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Acked-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Acked-by: Coly Li <colyli@suse.de>
---
 monitor.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/monitor.c b/monitor.c
index b877e595..820a93d0 100644
--- a/monitor.c
+++ b/monitor.c
@@ -311,6 +311,9 @@  static int check_for_cleared_bb(struct active_array *a, struct mdinfo *mdi)
 	struct md_bb *bb;
 	int i;
 
+	if (!ss->get_bad_blocks)
+		return -1;
+
 	/*
 	 * Get a list of bad blocks for an array, then read list of
 	 * acknowledged bad blocks from kernel and compare it against metadata