aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>2024-03-18 17:28:42 +0100
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>2024-03-22 12:16:41 +0100
commitae996e81232b8ba991e763dfa15577a0af358358 (patch)
tree6dcdff2c6e75e5dcfc4e98c7ba2b8acd12b5c184
parentde23e12a39cfc94575e1173293fe9e15337ee999 (diff)
downloadmdadm-ae996e81232b8ba991e763dfa15577a0af358358.tar.gz
mdadm: fix grow segfault for IMSM
If sc is not initialized, there is possibility that sc.pols is not zeroed and it causes segfault. Add missing initialization. Add missing dev_policy_free() in two places. Fixes: f656201188d7 ("mdadm: drop get_required_spare_criteria()") Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
-rw-r--r--Incremental.c1
-rw-r--r--super-intel.c9
2 files changed, 8 insertions, 2 deletions
diff --git a/Incremental.c b/Incremental.c
index 958ba9ba..83db0712 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -874,6 +874,7 @@ mdadm_status_t incremental_external_test_spare_criteria(struct supertype *st, ch
rv = MDADM_STATUS_SUCCESS;
out:
+ dev_policy_free(sc.pols);
dup->ss->free_super(dup);
free(dup);
diff --git a/super-intel.c b/super-intel.c
index ff2590fe..70f3c4ef 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -11518,10 +11518,15 @@ static int imsm_reshape_is_allowed_on_container(struct supertype *st,
*/
static struct mdinfo *get_spares_for_grow(struct supertype *st)
{
- struct spare_criteria sc;
+ struct spare_criteria sc = {0};
+ struct mdinfo *spares;
get_spare_criteria_imsm(st, NULL, &sc);
- return container_choose_spares(st, &sc, NULL, NULL, NULL, 0);
+ spares = container_choose_spares(st, &sc, NULL, NULL, NULL, 0);
+
+ dev_policy_free(sc.pols);
+
+ return spares;
}
/******************************************************************************