]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
monitor: Avoid segfault when calling NULL get_bad_blocks
authorLogan Gunthorpe <logang@deltatee.com>
Wed, 22 Jun 2022 20:25:10 +0000 (14:25 -0600)
committerJes Sorensen <jes@trained-monkey.org>
Sun, 7 Aug 2022 20:27:59 +0000 (16:27 -0400)
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>
Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
monitor.c

index b877e595c9989620195e7976d2079a3f9ef05775..820a93d0ceaf6aa6fc44618a14da3d3e136107c1 100644 (file)
--- 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