From efbae87c84a78fc0508921362254aa75735b4b85 Mon Sep 17 00:00:00 2001 From: Bobi Jam Date: Sat, 1 Jun 2024 11:24:08 -0700 Subject: [PATCH] LU-17773 lov: avoid partly outside array bounds build error MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Avoid "array subscript 'struct lov_stripe_md_entry[0]’ is partly outside array bounds of ‘struct lov_stripe_md_entry[0]’ error. Otherwise an lsme holder will be allocated for invalid lmm magic. Fixes: 902fe290 ("LU-17261 lov: ignore broken components") Signed-off-by: Bobi Jam Change-Id: I5a403a0d230d2129e372fd8a22f58901cd0c1b68 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54944 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Jian Yu Reviewed-by: Oleg Drokin --- lustre/lov/lov_ea.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/lustre/lov/lov_ea.c b/lustre/lov/lov_ea.c index 44dad1d..2755eb0 100644 --- a/lustre/lov/lov_ea.c +++ b/lustre/lov/lov_ea.c @@ -523,23 +523,8 @@ lsme_unpack_comp(struct lov_obd *lov, struct lov_mds_md *lmm, unsigned int magic; magic = le32_to_cpu(lmm->lmm_magic); - if (!lov_supported_comp_magic(magic)) { - struct lov_stripe_md_entry *lsme; - size_t lsme_sz = offsetof(typeof(*lsme), lsme_oinfo[0]); - struct lov_stripe_md_entry lsme_init = { - .lsme_pattern = le32_to_cpu(lmm->lmm_pattern), - .lsme_magic = magic, - }; - - /* allocate a lsme holder for invalid magic lmm */ - OBD_ALLOC_LARGE(lsme, lsme_sz); - if (!lsme) - return ERR_PTR(-ENOMEM); - - memcpy(lsme, &lsme_init, lsme_sz); - - return lsme; - } + if (!lov_supported_comp_magic(magic)) + RETURN(ERR_PTR(-EINVAL)); if (magic != LOV_MAGIC_FOREIGN && le16_to_cpu(lmm->lmm_stripe_count) == 0 && -- 1.8.3.1